Inserting Rows
Range("a8").Select
Dim lastrow As Long, formRow As Long
Dim i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
formRow = lastrow + 1
For i = lastrow To 10 Step -1
If Cells(i, 31) < Cells(i - 1, 31) Then
Cells(formRow, "K").Formula = "=SubTotal(9," & _
"K" & i & ":K" & formRow - 1 & ")"
Rows(i).insert shift:=xlShiftDown
formRow = i
End If
Next
--
Regards,
Tom Ogilvy
"Darryl" wrote:
I have the below code in a macro that by itself runs great. I want to stop it
at row 8. The data starts in row 9 and ends when it ends - the amount of rows
always varies. I have tried using different "Do", "Do Until" but have not
been successful. Any help would be greatly appreciated.
Darryl
Range("a8").Select
Dim lastrow As Long, formRow As Long
Dim i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
formRow = lastrow + 1
For i = lastrow To 2 Step -1
If Cells(i, 31) < Cells(i - 1, 31) Then
Cells(formRow, "K").Formula = "=SubTotal(9," & _
"K" & i & ":K" & formRow - 1 & ")"
Rows(i).insert shift:=xlShiftDown
formRow = i
End If
Next
|