billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
The code below inserts a row between data which is <> identical to the preceding cell in column A.
What I am unsure of is the lastrow to 3. In particular 3. Could someone provide explanation and or can this be observed line by line.
Thank You
Still learning
Sub insertRows()
Dim i As Integer
lastRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
For i = lastRow To 3 Step -1
If Range("A" & i).Value <> Range("A" & i - 1) Then
Rows(i).Resize(1).Insert
End If
Next
End Sub
What I am unsure of is the lastrow to 3. In particular 3. Could someone provide explanation and or can this be observed line by line.
Thank You
Still learning
Sub insertRows()
Dim i As Integer
lastRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row
For i = lastRow To 3 Step -1
If Range("A" & i).Value <> Range("A" & i - 1) Then
Rows(i).Resize(1).Insert
End If
Next
End Sub