View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Janis Janis is offline
external usenet poster
 
Posts: 360
Default macro to add 24 rows to each group in column H

I need to add 24 rows to each service group in column H. The field is SG1,
SG2, SG3. For each subtotaled group at the end I need to add the 24 rows.
The do until range line
has an error. I also don't know how to make the insert line add 24 instead
of only one. So this macro compares each offset row to see where the next
service group starts and that is where I want the insert.

Private Sub PutARowIn()
Range("H12").Select
Do Until Range(Range("R2"), Cells(Rows.Count, "R").End(xlUp))

If ActiveCell.Value = ActiveCell.Offset(-1, 0).Value Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.EntireRow.Insert
ActiveCell.Offset(2, 0).Select
End If
Loop
End Sub

thanks