Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert 3 Rows Every 10 Numbers 1

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
I was hoping someone could help me on this one.
I have this excel file.

Column A is numbered from one up to whatever(this number can vary)
I would like to insert 3 rows in after every 10 numbers

eg after number 10 in column A I want to insert 3 rows and after number 20 in column A I want to insert 3 rows etc

Thanking in advance for any help received
 
I would find the number of the last row, then do something like:
Code:
For x = LastRowNum To FirstRowNum Step -10
   For y = 1 To 3
      Rows(x & ":" & x).Insert
   Next y
Next x

Let me know if that's what you're after!


VBAjedi [swords]
 
I have put in the following code and nothing happens

Dim x As Integer, y As Integer

For x = 1 To 3000 Step -10
For y = 1 To 3
Rows(x & ":" & x).Insert
Next y
Next x
 
Well, I should have pointed out that you are working through the rows BACKWARDS when you use the "Step -10" syntax. So you need to list the bigger number first:

For x = 3000 To 1 Step -10

The reason you would want to use this approach is that by working from the bottom to the top it won't mess up your counter when you insert rows.


VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top