Thread: Insert rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul B[_7_] Paul B[_7_] is offline
external usenet poster
 
Posts: 73
Default Insert rows

Lost, don't know if this is the most efficient, but it works :) this code is
modified form one written by Barrie Davidson

Sub Insert_row_in_R()
Dim Number_of_rows As Long
Dim Rowinsert As Integer
Application.ScreenUpdating = False
Number_of_rows = Range("R65536").End(xlUp).Row
Rowinsert = 2
Range("R2").Select
Do Until Selection.Row = Number_of_rows + 1
If Selection.Value < Selection.Offset(-1, 0).Value Then
Selection.EntireRow.Resize(Rowinsert).Insert
Number_of_rows = Number_of_rows + Rowinsert
Selection.Offset(Rowinsert + 1, 0).Select
Else
Selection.Offset(1, 0).Select
End If
Loop
Application.ScreenUpdating = True
End Sub

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **


"Lost" wrote in message
...
I hope someone can help me with this confusing thing.

I have a large spreadsheet (20,000 rows +) and I have a
date in column R. The sheet has been sorted on column R.

I want the most efficient code I can find to insert two
rows everytime the a different date is found in column R.

Please supply your example code...and thanks millions...