stuartr87
08-31-2011, 09:19 AM
Hi All,
The consensus seems to be to use a case select rather than the FormatConditions method to when conditionally formatting using VBA.
I'm writing a macro to create a spreadsheet template that may then be populated with data. I wish to apply conditional formatting to a column of cells that will contain either "A", "B" or "C" and fill red, green or orange respectively. Unfortunately, I'm having a little trouble with what I think is a pretty straightforward syntax and hoped someone could suggest my error.
I assumed that this line would be sufficient for the first condition:
Range("B4:B20").FormatConditions.Add(xlCellValue, xlEqual, "A").Interior.Color = RGB(255,0,0)
however VBA reports a syntax error.
Any suggestions would be greatly appreciated...it can't be this hard!
Many thanks,
Stuart
The consensus seems to be to use a case select rather than the FormatConditions method to when conditionally formatting using VBA.
I'm writing a macro to create a spreadsheet template that may then be populated with data. I wish to apply conditional formatting to a column of cells that will contain either "A", "B" or "C" and fill red, green or orange respectively. Unfortunately, I'm having a little trouble with what I think is a pretty straightforward syntax and hoped someone could suggest my error.
I assumed that this line would be sufficient for the first condition:
Range("B4:B20").FormatConditions.Add(xlCellValue, xlEqual, "A").Interior.Color = RGB(255,0,0)
however VBA reports a syntax error.
Any suggestions would be greatly appreciated...it can't be this hard!
Many thanks,
Stuart