Results 1 to 3 of 3

Unable to create VBA coding for Text Box Click event

Threaded View

zero_eclipse Unable to create VBA coding... 10-26-2012, 07:30 AM
JosephP Re: Unable to create VBA... 10-26-2012, 07:45 AM
zero_eclipse Re: Unable to create VBA... 10-26-2012, 08:14 AM
  1. #1
    Registered User
    Join Date
    08-04-2012
    Location
    Gloucester, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Unable to create VBA coding for Text Box Click event

    Hi All,

    I'm hoping someone will be able to assist me; I am having difficulty creating a MS Excel 2003 VBA Click Event for a text box to change the fill colour. There are twelve Text Box's grouped together pertaining to each month of the year and the idea is to alter the colour depending on a Red, Amber, Green Performance. The coding below works as a freeform click event however for a Text Box it returns a runtime error 70.
    Sub TextBox862_Click()
    With ActiveSheet.Shapes("Text Box 862")
    If .Fill.ForeColor.SchemeColor = 9 Then
    .Fill.ForeColor.SchemeColor = 11
    ElseIf .Fill.ForeColor.SchemeColor = 11 Then
    .Fill.ForeColor.SchemeColor = 52
    ElseIf .Fill.ForeColor.SchemeColor = 52 Then
    .Fill.ForeColor.SchemeColor = 10
    ElseIf .Fill.ForeColor.SchemeColor = 10 Then
    .Fill.ForeColor.SchemeColor = 9
    End If
    End With
    I have tried using Macro Recorder to find another method to no avail. However, below are the parameters for colour coding I wish to achieve.
    Sub TextBox439_Click()
        ActiveSheet.Shapes("Text Box 439").
        Selection.ShapeRange.Fill.Transparency = 0#
        Selection.ShapeRange.Line.Weight = 0.5
        Selection.ShapeRange.Line.DashStyle = msoLineSolid
        Selection.ShapeRange.Line.Style = msoLineSingle
        Selection.ShapeRange.Line.Transparency = 0#
        Selection.ShapeRange.Line.Visible = msoTrue
        Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
        Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
        Selection.ShapeRange.Fill.Visible = msoTrue
        Selection.ShapeRange.Fill.ForeColor.SchemeColor = 10
        Selection.ShapeRange.Fill.OneColorGradient msoGradientFromCenter, 2, 0.79
        ActiveSheet.Shapes("Text Box 439").Select
        End With
        Selection.ShapeRange.Fill.Transparency = 0#
        Selection.ShapeRange.Line.Weight = 0.5
        Selection.ShapeRange.Line.DashStyle = msoLineSolid
        Selection.ShapeRange.Line.Style = msoLineSingle
        Selection.ShapeRange.Line.Transparency = 0#
        Selection.ShapeRange.Line.Visible = msoTrue
        Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
        Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
        Selection.ShapeRange.Fill.Visible = msoTrue
        Selection.ShapeRange.Fill.ForeColor.SchemeColor = 52
        Selection.ShapeRange.Fill.OneColorGradient msoGradientFromCenter, 2, 0.79
        End With
        Selection.ShapeRange.Fill.Transparency = 0#
        Selection.ShapeRange.Line.Weight = 0.5
        Selection.ShapeRange.Line.DashStyle = msoLineSolid
        Selection.ShapeRange.Line.Style = msoLineSingle
        Selection.ShapeRange.Line.Transparency = 0#
        Selection.ShapeRange.Line.Visible = msoTrue
        Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
        Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
        Selection.ShapeRange.Fill.Visible = msoTrue
        Selection.ShapeRange.Fill.ForeColor.SchemeColor = 9
        Selection.ShapeRange.Fill.OneColorGradient msoGradientFromCenter, 2, 0.79
        End With
        Selection.ShapeRange.Fill.Transparency = 0#
        Selection.ShapeRange.Line.Weight = 0.5
        Selection.ShapeRange.Line.DashStyle = msoLineSolid
        Selection.ShapeRange.Line.Style = msoLineSingle
        Selection.ShapeRange.Line.Transparency = 0#
        Selection.ShapeRange.Line.Visible = msoTrue
        Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
        Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
        Selection.ShapeRange.Fill.Visible = msoTrue
        Selection.ShapeRange.Fill.ForeColor.RGB = RGB(51, 204, 51)
        Selection.ShapeRange.Fill.OneColorGradient msoGradientFromCenter, 2, 0.79
    End Sub
    Can anyone please help, I have tried different connotations and still struggling.
    Last edited by JosephP; 10-26-2012 at 07:40 AM. Reason: add code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1