Autoinsert Rows
Autoinsert Rows
(OP)
I have a large chunk of some production data - some 4000 lines and have it sorted by date. Is there a way to automatically segment the data so that I can put in a line or two under each date or to separate the data day-by-day so that I can minipulate certaion portions of the data?





RE: Autoinsert Rows
How do you want to manipulate the data? Would a simple filter do the trick for you?
RE: Autoinsert Rows
Sub insert_rows()
' Last row with data in it
last_data_row = 4000
' Number of rows to insert
numrows=2
For i = last_data_row To 1 Step -1
Rows(i & ":" & (i + (numrows-1))).Select
Selection.Insert Shift:=xlDown
Next i
End Sub
RE: Autoinsert Rows
This routine does the following:
1. Determine the last row used.
2. Working from the last row used upwards it compares
the value of column A in the current row to column A in
the row above.
if they are the same nothing happens.
If they differ then 2 rows are inserted.
Dim i As Long, LastRow As Long
Application.ScreenUpdating = False
'finds last used row in column A
LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 1 Step -1
If i >= 2 Then
If Cells(i, "A") <> Cells(i - 1, "A") Then
Rows(i).Insert 'add 1 blank row
Rows(i).Insert 'add another blank row
End If
Else
End
End If
Next i
Application.ScreenUpdating = True
RE: Autoinsert Rows