I have this macro that adds an empty row (only column A will contain a value same as the cell above it) between two rows that contain different values in column B
in the example file below, a new row is added after rows: 14, 20, 27. The code is doing everything that it was intended to do except it adds "0" to column K in the new row...
any idea what is causing this ? Thanks !
in the example file below, a new row is added after rows: 14, 20, 27. The code is doing everything that it was intended to do except it adds "0" to column K in the new row...
any idea what is causing this ? Thanks !
VBA Code:
Sub BlankSpaceBetweenStructures()
Dim lr As Long, r As Long
Application.ScreenUpdating = False
lr = Cells(Rows.Count, "B").End(xlUp).Row
For r = lr To 3 Step -1
If Cells(r, "B").Value <> Cells(r - 1, "B").Value Then
Rows(r).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(r, "A").Value = Cells(r - 1, "A").Value
End If
Next r
Application.ScreenUpdating = True
End Sub