hi all, i am using the below code to select sheet 2 column "o" and apply conditional formatting to values in column "o" . The issue I have is that for some reason the conditional formatting is being applied to 4993 rows. There are only 49 rows of data, looking at the CF formula it reads =$O$2:$O$4993. The odd thing is that in column a I have employee ID numbers and when summed they = 4993. is there a way to alter the code so that it doesn't count the values in column a and just apply it to values in column o?
Any assistance would be much appreciated.
Any assistance would be much appreciated.
Code:
Sub CellCCondFormatting()
' This procdure will colour column O values greater and less than 30 credits
Sheets("sheet2").Select
Dim j As Long
Range("o2").Select
j = Range("o2").CurrentRegion.Rows.Count
With Range("o2:o" & j)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlGreater, _
Formula1:="=30"
.FormatConditions(1).Interior.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlLess, _
Formula1:="=30"
.FormatConditions(2).Interior.ColorIndex = 4
End With
End Sub
Last edited by a moderator: