I'm a beginner in vba and I would like a script for add 1 rule on all line(201 lines).
My counter is i
and I want insert this i
for an automatic increment in my worksheet
I don't know why I can't insert a variable?
Sub test()
Dim i As Byte
i = 2
While (i <= 202)
Range("Hi,Hi:Ji,Mi:Pi").Select '<--- insert my "i" here
Range("Mi").Activate '<---here
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=$G$i" '< ---here
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 192
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
i = i + 1
Wend
End Sub