My code below goes into an infinite loop, with culprit line shown in bold and underline. Please help identify error in my code logic. Thank you
Code
Worksheets("Sheet2").Select
ActiveSheet.Range("A4").Select
For ColIndex = 1 To Range(ActiveCell, ActiveCell.EntireRow.Cells(1, Columns.Count).End(xlToLeft)).Columns.Count
If Cells(4, ColIndex) = "" Then
Range(Cells(3, ColIndex), Cells(4, ColIndex)).Delete Shift:=xlShiftToLeft
[B][U]ColIndex = ColIndex - 1[/U][/B]
ElseIf Cells(4, ColIndex).Value = Cells(4, ColIndex + 1).Value Then
Range(Cells(3, ColIndex + 1), Cells(4, ColIndex + 1)).Delete Shift:=xlShiftToLeft
ColIndex = ColIndex - 1
End If
Next ColIndex
Display More