Hello all,
I am using a countif formula on a range in all sheets in a workbook (specifically range P2 to P500). If the occurence is >= 2 then I want to colour the background in the cell blue, however I want to do this accross all worksheets in the active workbook. For some reason it does not work, can anyone see what I have done wrong?
Code
Sub duplicates()
Dim cell As Range
Const Colour = 5
Dim wks As Worksheet
Dim r As Range
Set r = Range("p2:p500")
Application.ScreenUpdating = False
For Each wks In ActiveWorkbook.Worksheets
For Each cell In r
Select Case cell.Value
Case Is < 2
cell.Interior.ColorIndex = xlNone
Case Is = ""
cell.Interior.ColorIndex = xlNone
Case Is >= 2
cell.Interior.ColorIndex = Colour
End Select
Next cell
Next wks
Application.ScreenUpdating = True
End Sub
Display More
:thanx:
Robert