I want this macro to select range C6:N6, apply a format condition, step 7 and so on until the end of my list. When i execute it, it bings me an error regarding the objects.
I think my problem is on the following part:
For i = 6 To lastRow Step 7
Range(C & i, N & i).Select
This way I want to make the ranges variable. Below is my code:
Sub test1()
' Coluna C
Dim lastRow As Long
lastRow = Cells(Rows.Count, 1).End(xlUp).Row ' Pega ultima celula com valores na coluna C
For i = 6 To lastRow Step 7
Range(C & i, N & i).Select 'what am i missing?
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Next i
End Sub