Hello
I have this code for searching a column when a number changes and insert rows above and below when there is a change.
Sub InsertRows()
Dim lastRow As Long
Dim rowPtr As Long
lastRow = Range("C" & Rows.Count).End(xlUp).Row
For rowPtr = lastRow To 2 Step -2
If Not IsEmpty(Range("C" & rowPtr)) Then
If Range("C" & rowPtr) <> Range("C" & rowPtr - 1) Then
Range("C" & rowPtr).EntireRow.Insert
End If
End If
Next
End Sub
So fx. Column C:
1
1
1
2
2
Have to be:
new row = "Text"
1
1
1
new row "Text 2"
new row "text"
2
2
new row "text 2"
new row "Text"
So when a new value begins: "Text"
When it ends, "text 2"
When the new value begins, same "text"
when it ends, same "text 2
Appreciate any help.
Kind regards
Bookmarks