Hi all,
I am trying to use a userform (Combo Box) to update my named cell "Aircraft1" then based on the value selected change the color of an object.
The code works great if I manually enter the value in the cell "Aircraft1", however if the dropdown list selects the value the object does not update its color.
Is there a way to update the cell via a combo box, and then have the VB code change the color of the object?
Thanks in advance for any possible solution to my problem.
This is my code:
Code
- Option Explicit
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Intersect(Target, Range("Aircraft1")) Is Nothing Then Exit Sub
- ActiveSheet.Shapes("Arrow1").Select
- With Range("Aircraft1")
- If .Value = 1 Then
- ActiveSheet.Shapes("Arrow1").Select
- Selection.ShapeRange.Fill.Visible = msoTrue
- Selection.ShapeRange.Fill.Solid
- Selection.ShapeRange.Fill.ForeColor.SchemeColor = 17
- Selection.ShapeRange.Fill.Transparency = 0#
- Selection.ShapeRange.Line.Weight = 0.75
- Selection.ShapeRange.Line.DashStyle = msoLineSolid
- Selection.ShapeRange.Line.Style = msoLineSingle
- Selection.ShapeRange.Line.Transparency = 0#
- Selection.ShapeRange.Line.Visible = msoTrue
- Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
- Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
- Selection.ShapeRange.LockAspectRatio = msoFalse
- Selection.ShapeRange.Height = 21#
- Selection.ShapeRange.Width = 18#
- Selection.ShapeRange.Rotation = 0#
- ElseIf .Value = 2 Then
- ActiveSheet.Shapes("Arrow1").Select
- Selection.ShapeRange.Fill.Visible = msoTrue
- Selection.ShapeRange.Fill.Solid
- Selection.ShapeRange.Fill.ForeColor.SchemeColor = 12
- Selection.ShapeRange.Fill.Transparency = 0#
- Selection.ShapeRange.Line.Weight = 0.75
- Selection.ShapeRange.Line.DashStyle = msoLineSolid
- Selection.ShapeRange.Line.Style = msoLineSingle
- Selection.ShapeRange.Line.Transparency = 0#
- Selection.ShapeRange.Line.Visible = msoTrue
- Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
- Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
- Selection.ShapeRange.LockAspectRatio = msoFalse
- Selection.ShapeRange.Height = 21#
- Selection.ShapeRange.Width = 18#
- Selection.ShapeRange.Rotation = 0#
- ElseIf .Value > 2 Then
- ActiveSheet.Shapes("Arrow1").Select
- Selection.ShapeRange.Fill.Visible = msoTrue
- Selection.ShapeRange.Fill.Solid
- Selection.ShapeRange.Fill.ForeColor.SchemeColor = 10
- Selection.ShapeRange.Fill.Transparency = 0#
- Selection.ShapeRange.Line.Weight = 0.75
- Selection.ShapeRange.Line.DashStyle = msoLineSolid
- Selection.ShapeRange.Line.Style = msoLineSingle
- Selection.ShapeRange.Line.Transparency = 0#
- Selection.ShapeRange.Line.Visible = msoTrue
- Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
- Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
- Selection.ShapeRange.LockAspectRatio = msoFalse
- Selection.ShapeRange.Height = 21#
- Selection.ShapeRange.Width = 18#
- Selection.ShapeRange.Rotation = 180#
- End If
- .Select
- End With
- End Sub