visual basic code

Joined
Jan 25, 2005
Messages
5
Hi;

I need to insert rows within excel; 2000 rows to be exact and these are in multiple spreadsheets. Is there a macro/visual basic code I can use to run this? I know something with a do until (last row) would work but dont know how to tell excel to move insert after skipping two rows, and then inserting, and then skipping etc etc

thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I think a little more info is needed to help you solve your problem. Do you need to insert a row at every third row for all sheets in one workbook? Which columns have data in them? Would you stop inserting rows after 2000, even if there's more data in the sheet?
 
Upvote 0
How about this:
Code:
Sub rowinsert()
Dim r As Double
Dim count As Double

r = 1
count = 1

Do Until count >= 2000
Cells(r, 1).EntireRow.Insert
count = count + 1
r = r + 3
Loop

End Sub

If you don't want to start on the first row, then change r=1 to whatever row number you want to start on.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,432
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top