Zero_Eclipse
New Member
- Joined
- Jul 17, 2012
- Messages
- 20
Hi all,
I am currently attempting to build a strategic assesment report for my department using Windows XP MS Excel 2003; unfortunately the requirement is for an automated system without buying an off the shelf package and quite frankly this has caused me sleepless nights, as I have never worked with visual basic before, and teaching myself over the last few days has achieved very little.
I have a workbook with multiple worksheets, on each worksheet (2 onwards) cells C21 to C23 contain dropdown lists (created via validation and have corresponding conditional formatting (R.A.G)). The drop downs list High, Medium or Low as options and the cells will turn Red, Amber or Green accordingly. On worksheet 1 there are Traffic lights (drawn using autoshapes and one for each worksheet). Cell C21 on each sheet will link to the first bulb in a corresponding traffic light image. Cell C22 links to the second bulb and Cell C23 links to the third bulb. Each bulb needs to turn Red, Amber or Green when the corresponding cell is selected as High, Medium or Low.
I have tried pasting the below into view code on each worksheet amending as required to match the worksheet and autoshapes as required, but to no avail.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$21" Then
'Change autoshape color to red, amber or green depending upon cell value.
With WorksheetSheet1.Shapes("Autoshape 6").Fill.ForeColor
If Target.Value = "High" Then
.SchemeColor = 3
ElseIf Target.Value = "Medium" Then
.SchemeColor = 45
ElseIf Target.Value = "Low" Then
.SchemeColor = 51
End If
End With
End If
If Target.Address = "$C$22" Then
'Change autoshape color to red, amber or green depending upon cell value.
With WorksheetSheet1.Shapes("Autoshape 2").Fill.ForeColor
If Target.Value = "High" Then
.SchemeColor = 3
ElseIf Target.Value = "Medium" Then
.SchemeColor = 45
ElseIf Target.Value = "Low" Then
.SchemeColor = 51
End If
End With
End If
If Target.Address = "$C$23" Then
'Change autoshape color to red, amber or green depending upon cell value.
With WorksheetSheet1.Shapes("Autoshape 3").Fill.ForeColor
If Target.Value = "High" Then
.SchemeColor = 3
ElseIf Target.Value = "Medium" Then
.SchemeColor = 45
ElseIf Target.Value = "Low" Then
.SchemeColor = 51
End If
End With
End If
End Sub
Please can anyone help me as I really am struggling.
I am currently attempting to build a strategic assesment report for my department using Windows XP MS Excel 2003; unfortunately the requirement is for an automated system without buying an off the shelf package and quite frankly this has caused me sleepless nights, as I have never worked with visual basic before, and teaching myself over the last few days has achieved very little.
I have a workbook with multiple worksheets, on each worksheet (2 onwards) cells C21 to C23 contain dropdown lists (created via validation and have corresponding conditional formatting (R.A.G)). The drop downs list High, Medium or Low as options and the cells will turn Red, Amber or Green accordingly. On worksheet 1 there are Traffic lights (drawn using autoshapes and one for each worksheet). Cell C21 on each sheet will link to the first bulb in a corresponding traffic light image. Cell C22 links to the second bulb and Cell C23 links to the third bulb. Each bulb needs to turn Red, Amber or Green when the corresponding cell is selected as High, Medium or Low.
I have tried pasting the below into view code on each worksheet amending as required to match the worksheet and autoshapes as required, but to no avail.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$21" Then
'Change autoshape color to red, amber or green depending upon cell value.
With WorksheetSheet1.Shapes("Autoshape 6").Fill.ForeColor
If Target.Value = "High" Then
.SchemeColor = 3
ElseIf Target.Value = "Medium" Then
.SchemeColor = 45
ElseIf Target.Value = "Low" Then
.SchemeColor = 51
End If
End With
End If
If Target.Address = "$C$22" Then
'Change autoshape color to red, amber or green depending upon cell value.
With WorksheetSheet1.Shapes("Autoshape 2").Fill.ForeColor
If Target.Value = "High" Then
.SchemeColor = 3
ElseIf Target.Value = "Medium" Then
.SchemeColor = 45
ElseIf Target.Value = "Low" Then
.SchemeColor = 51
End If
End With
End If
If Target.Address = "$C$23" Then
'Change autoshape color to red, amber or green depending upon cell value.
With WorksheetSheet1.Shapes("Autoshape 3").Fill.ForeColor
If Target.Value = "High" Then
.SchemeColor = 3
ElseIf Target.Value = "Medium" Then
.SchemeColor = 45
ElseIf Target.Value = "Low" Then
.SchemeColor = 51
End If
End With
End If
End Sub
Please can anyone help me as I really am struggling.
Last edited: