Diving_Dan
Board Regular
- Joined
- Oct 20, 2019
- Messages
- 161
Morning all,
I'm having a few issues trying to write some code for conditional formatting. I'm going to be adding a loop shortly but want to get this working first.
So I get an error "Expected: end of statement" with the following code for the 2nd line of code.
I know the issue is because of the quotes around "role" but I need the quotes because of the formula. How do I make this work?
I'm having a few issues trying to write some code for conditional formatting. I'm going to be adding a loop shortly but want to get this working first.
So I get an error "Expected: end of statement" with the following code for the 2nd line of code.
I know the issue is because of the quotes around "role" but I need the quotes because of the formula. How do I make this work?
VBA Code:
Sub add_con_formatting()
Range("h11").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=G11="role""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("C6").Select
End Sub