ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conditional formatting to drawing objects. (https://www.excelbanter.com/excel-programming/288851-conditional-formatting-drawing-objects.html)

borde

conditional formatting to drawing objects.
 
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".

Debra Dalgleish

conditional formatting to drawing objects.
 
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
'===================================

borde wrote:
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".



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com