conditional formatting to drawing objects.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a "line" drawing object drawn in some sketch. I want to change this line color to red if the cell value A1 ="R",and make the line color to green if A1="L".
 
You could use a Worksheet_Change event to change the line colour when
the value in cell A1 is changed. The following code goes into the
sheet's module (right-click the sheet tab, choose View Code, and paste
the code onto the module sheet, where the cursor is flashing).

In this example, the Line is named Line 2. To see the name of your line,
select the line, and look in the Name Box, at the left end of the
formula bar.

'==================================
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Address = "$A$1" Then
If UCase(Target.Value) = "R" Then
ActiveSheet.Shapes("Line 2") _
.Line.ForeColor.SchemeColor = 10
Else
If UCase(Target.Value) = "L" Then
ActiveSheet.Shapes("Line 2") _
.Line.ForeColor.SchemeColor = 17
End If
End If
End If

End Sub
'===================================
 
Back
Top