I am trying to remove the standard Conditional Formatting I initially added from a sheet as I found that over time, there ended up being so many rules listed and the sheet became seriously slow. After deleting all the CF, it is now behaving as it should, but I still need to colour those columns.
So I am trying to write a VBA macro to handle the individual columns, but have a section which remain red, telling me the syntax is not correct.
Here is the code to date
As you can see, there is a group of 3 columns together (AQ to AS) then 5 individual columns (BH, BK, BN, BQ & BT).
The entire section for Set MyRange remains red. That seems to be the only area in question.
Any thoughts on what I am doing wrong in that section?
cheers
So I am trying to write a VBA macro to handle the individual columns, but have a section which remain red, telling me the syntax is not correct.
Here is the code to date
VBA Code:
Sub ConditionalFormattingPowerSheets()
Dim MyRange As Range
'Create range object
Set MyRange = Union(.Range(“AQ21:AS" & LastRow),.Range(“BH21:BH" &LastRow),.Range, _
(“BK21:BK" & LastRow),.Range(“BN21:BN" & LastRow),.Range(“BQ21:BQ” & LastRow),.Range, _
(“BT21:BT" & LastRow))
'Delete previous conditional formats
MyRange.FormatConditions.Delete
'Add first rule
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, _
Formula1:=“=0"
MyRange.FormatConditions(1).Interior.Color = RGB(167, 255, 167)
'Add second rule
MyRange.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=0"
MyRange.FormatConditions(2).Interior.Color = RGB(251, 178, 178)
End Sub
As you can see, there is a group of 3 columns together (AQ to AS) then 5 individual columns (BH, BK, BN, BQ & BT).
The entire section for Set MyRange remains red. That seems to be the only area in question.
Any thoughts on what I am doing wrong in that section?
cheers