LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Automatically Insert Rows

Markus,

assuming your "numbers" column is in the range A1:A...
then this nasty little routine should sort it out for you.
If you have any problems getting it to run, it may be
because the Usedrange is different from what you think. If
that happens, replace "LastRow" in the "For.." statement
with the number of the last line in your list:

Sub AddRows()

LastRow = ActiveSheet.UsedRange.Rows.Count
For x = LastRow To 2 Step -1

If Cells(x, 1).Value < (Cells(x - 1, 1).Value + 1) Then
Rows(x).Insert
Cells(x, 1).Value = Cells(x + 1, 1).Value - 1
x = x + 1
End If


Next x

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically Insert New Rows petitpiti Excel Discussion (Misc queries) 1 February 28th 11 09:18 AM
Insert a rows automatically jetanddug Excel Worksheet Functions 3 October 31st 09 03:15 AM
How do I automatically insert rows colwyn Excel Discussion (Misc queries) 13 September 11th 08 09:16 PM
Automatically Insert New Rows Eric Excel Discussion (Misc queries) 0 June 12th 07 10:54 PM
Automatically insert/delete rows to be x apart Mr_Flibble Excel Discussion (Misc queries) 5 February 17th 06 04:04 AM


All times are GMT +1. The time now is 07:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"