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.
Bookmarks