Insert Multi Rows Between Existing Data

Solved/Closed
froggy6703 - Mar 6, 2010 at 11:18 AM
 SWAJI - Nov 19, 2014 at 07:02 AM
Hello,

I am trying to create a macro that will insert a set amount of blank rows into a existing spreadsheet after each entry. The amount of rows needed will be the same for each entry on the spreadsheet, but will need to be changed each time it is used.

Here is a sample...
Currently:
Title1
Title2
Title3
Title4

After Macro:
Title1


Title2


Title3


Title4

The amount of blank row can be anywhere from 20 - 40. I am hoping I can use some sort of Input box to get the number of rows needed so I don't need to modify to code each time.

Thank you and let me know if you can help.

Matt
Related:

5 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Mar 6, 2010 at 09:47 PM
A1 is having headings.
then try this macro
KEEP YOUR ORIGINAL FILE SAFELY SOMEWHERE
FIRST DO THE TESTING OF MACRO IN THE EXPERIMENTAL DATA YOU HAVE SENT
Sub test()
Dim j As Long, r As Range
j = InputBox("type the number of rows to be insered")
Set r = Range("A2")
Do
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
MsgBox r.Address
If r.Offset(1, 0) = "" Then Exit Do
Loop

End Sub
14
This works great, thank you for your quick response. The only thing I don't like is the pop-up box that tells you where the cell was entered. This is good to have but the spreadsheets I am working with can have up to 500-1000 lines. Meaning I have to hit Enter 500-1000 times to get through them all. Is it possible to remove that pop-up box?

Thanks again,

Matt
0
yes, just delete the line "MsgBox r.Address"
0