ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inserting several new rows (https://www.excelbanter.com/excel-discussion-misc-queries/173508-inserting-several-new-rows.html)

richzip

Inserting several new rows
 
I have a spreadsheet with about 1500 rows. I want to insert 18 black rows
after each existing row. Is there a quick way of doing this without having
to do this after each row?

Pete_UK

Inserting several new rows
 
That will give you 27,000 rows - are you sure this is what you want to
do? And I presume you meant 18 blank rows rather than black rows?

Pete

On Jan 17, 11:00*pm, richzip
wrote:
I have a spreadsheet with about 1500 rows. *I want to insert 18 black rows
after each existing row. *Is there a quick way of doing this without having
to do this after each row?



Gord Dibben

Inserting several new rows
 
Sub Insert_Some_Rows()
Application.ScreenUpdating = False
Dim numRows As Integer
Dim R As Long
numRows = InputBox("Enter number of blank rows to insert")
R = Cells(Rows.Count, "A").End(xlUp).Row
For R = R To 1 Step -1
ActiveSheet.Rows(R + 1).Resize(numRows).Insert
Next R
Application.ScreenUpdating = True
End Sub

If you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or Ron de De Bruin's site on where to store macros.

http://www.rondebruin.nl/code.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP

On Thu, 17 Jan 2008 15:00:02 -0800, richzip
wrote:

I have a spreadsheet with about 1500 rows. I want to insert 18 black rows
after each existing row. Is there a quick way of doing this without having
to do this after each row?




All times are GMT +1. The time now is 01:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com