In column B (5000+ rows long), I have a macro to insert a blank row whenever the value in Column B changes.
The problem is that it is taking quite a long time.
Is there anyway to optimise the macro to make it more efficient/run faster? Thanks.
VBA Code:
Sub InsertNewRowAtChange()
Dim lastRow As Long
Dim i As Long
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = lastRow To 2 Step -1
If Range("A" & i).Value <> Range("A" & i - 1).Value Then
Rows(i).Insert Shift:=xlDown
End If
Next i
End Sub
The problem is that it is taking quite a long time.
Is there anyway to optimise the macro to make it more efficient/run faster? Thanks.