When I modify macro for my needs, I get "debug":
Sub Test1()
Dim rng As Range, cell As Range
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("FL3:FL" & lr)
For Each cell In rng
If cell <> "" And cell > cell.Offset(0, 1) Then
For i = 0 To 52 - cell + cell.Offset(0, 1)
If cell + i > 52 Then
Cells(cell.Row, 170 + i) = (cell + i) Mod 52
Else
Cells(cell.Row, 170 + i) = cell + i
End If
Next i
Else
For i = 0 To cell.Offset(0, 1) - cell
Cells(cell.Row, 170 + i) = cell + i
Next i
End If
Next cell
End Sub
Any ideas why?
Bookmarks