Hi,
I am using the below formula to select cells for conditional formatting:
Range("A2:A45,F2:F45").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B2=$F2"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 5287936
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("A2:A45,F2:F45").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B2<>$F2"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
It works from A2 to A45 and F2 to F45 but i need to copy down to the last active row on the sheet. I currently use:
Dim LR As Long
LR = Cells(Rows.Count, 1).End(xlUp).Row
But how do i change Range("A2:A45,F2:F45").Select to use LR?
Thanks
I am using the below formula to select cells for conditional formatting:
Range("A2:A45,F2:F45").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B2=$F2"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 5287936
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
Range("A2:A45,F2:F45").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B2<>$F2"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
It works from A2 to A45 and F2 to F45 but i need to copy down to the last active row on the sheet. I currently use:
Dim LR As Long
LR = Cells(Rows.Count, 1).End(xlUp).Row
But how do i change Range("A2:A45,F2:F45").Select to use LR?
Thanks