Avatar of Sanjay Gandhi
Sanjay Gandhi
Flag for India asked on

Insert 4 blank rows against every name in Excel

Hi,

Want to create blank rows where I can later add Q1 to Q4 as entries in the data.

There are some 50-60 names in a column. Against every name, I want 4 blank rows to be inserted, so that I can paste Q1 to Q4 in those blank rows against each name.

Excel file is attached, this will help.

Create Blank Rows.xlsx

Thanks,

San.

Microsoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Martin Liss

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Sanjay Gandhi

ASKER
Thanks Martin,
Your answer helped me create this code.

Sub InsertRows()
   '
   ' Insert  rows from last row
   '
   Dim NextRow_ll As Long, LastRow_ll As Long
   
   LastRow_ll = Range("D10000").End(xlUp).Row
   
   For NextRow_ll = LastRow_ll To 6 Step -1
       Range("D" & NextRow_ll & ":D" & NextRow_ll + 2).EntireRow.Insert
   Next

End Sub


Open in new window

Martin Liss

I've modified my code to insert the Qs.

Sub Insert4()
Dim lngLastRow As Long
Dim lngRow As Long

lngLastRow = Range("D1048576").End(xlUp).Row

For lngRow = lngLastRow To 6 Step -1
    Cells(lngRow, "D").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Cells(lngRow, "D").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Cells(lngRow, "D").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next

lngLastRow = Range("D1048576").End(xlUp).Row
For lngRow = 5 To lngLastRow Step 4
    Cells(lngRow, "E") = "Q1"
    Cells(lngRow + 1, "E") = "Q2"
    Cells(lngRow + 2, "E") = "Q3"
    Cells(lngRow + 3, "E") = "Q4"
    If lngRow = lngLastRow Then
        Exit For
    End If
Next

End Sub

Open in new window

Martin Liss

You’re welcome and I’m glad I was able to help, and thank you for the testimonial.

If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Distinguished Expert in Excel 2018
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2020
              Experts Exchange Top Expert VBA 2018 to 2020
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy