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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
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?
 

yankee428

Active Member
Joined
Apr 12, 2004
Messages
348
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.
 

Forum statistics

Threads
1,147,845
Messages
5,743,513
Members
423,801
Latest member
paulj4177

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
Top