Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to copy and insert row multiple times or duplicate the row x times in Excel?

In your daily work, have you ever tried to copy a row or each row and then insert multiple times below the current data row in a worksheet? For example, I have a range of cells, now, I want to copy each row and paste them 3 times to next row as following screenshot shown. How could you deal with this job in Excel?

doc copy insert x times 1

Copy and insert a specific row multiple times with VBA code

Copy and insert each row multiple times with VBA code

Copy and insert a specific row for every other or nth row with Kutools for Excel


arrow blue right bubble Copy and insert a specific row for every other or nth row with Kutools for Excel

Copy and insert a specific row for every other or nth row

With Kutools for Excel's Insert Titles Rows feature, you can quickly copy and insert a specific row for every other or nth row at once.

doc copy insert x times 5

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Copy and insert a specific row multiple times with VBA code

If you want to duplicate only one specific row x times, the following VBA code may help you, please do as this:

1. Specify a row which you want to copy and insert multiple times, and then hold down the ALT + F11 keys, then it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Duplicate one specific row multiple times:

Sub test()
'Updateby Extendoffice 20160616
    Dim xCount As Integer
LableNumber:
    xCount = Application.InputBox("Number of Rows", "Kutools for Excel", , , , , , 1)
    If xCount < 1 Then
        MsgBox "the entered number of rows is error, please enter again", vbInformation, "Kutools for Excel"
        GoTo LableNumber
    End If
    ActiveCell.EntireRow.Copy
    Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(xCount, 0)).EntireRow.Insert Shift:=xlDown
    Application.CutCopyMode = False
End Sub

3. After pasting the code, please press F5 key to run this code, and a prompt box is popped out to remind you enter the number of times that you want to duplicate, see screenshot:

doc copy insert x times 2

4. Then click OK button, and four new copied rows have been inserted below the selected row, see screenshot:

doc copy insert x times 3


arrow blue right bubble Copy and insert each row multiple times with VBA code

To duplicate each rows multiple times in a range, you can apply the following VBA code, please do as below:

1. Hold down the ALT + F11 keys, then it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Duplicate each row multiple times:

Sub insertrows()
'Updateby Extendoffice 2016616
    Dim I As Long
    Dim xCount As Integer
LableNumber:
    xCount = Application.InputBox("Number of Rows", "Kutools for Excel", , , , , , 1)
    If xCount < 1 Then
        MsgBox "the entered number of rows is error ,please enter again", vbInformation, "Kutools for Excel"
        GoTo LableNumber
    End If
    For I = Range("A" & Rows.CountLarge).End(xlUp).Row To 1 Step -1
        Rows(I).Copy
        Rows(I).Resize(xCount).Insert
    Next
    Application.CutCopyMode = False
End Sub

3. And then press F5 key to run this code, and a prompt box is popped out to remind you enter the number of times that you want to duplicate for each record, see screenshot:

doc copy insert x times 4

4. Then click OK, and each row has been copied and inserted 3 times below the active ones, see screenshot:

doc copy insert x times 1

Note: In the above code, the A indicates the data range is started at the column A, if your data starts at column K, please change A to K as your need.


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Jamar · 1 months ago
    How can I do this for columns?
  • To post as a guest, your comment is unpublished.
    Jamar · 1 months ago
    how do I do this for columns?
  • To post as a guest, your comment is unpublished.
    Andreea · 4 months ago
    Love it! It works every time! Thank you so much for this :)
  • To post as a guest, your comment is unpublished.
    Sashitharan Govindasamy · 7 months ago
    Hello, I need help, this is how my table looks, for example, when I add 2 row at the end of my 1st table, I want the vba help me to do the same thing for the table below (add 2 rows at the end of the table). So my job will be, only need to add rows at the 1st table, the table bellows all will generate rows automatically based on numbers of row in the 1st table. the are the coding I used now to add row for the 1st table. I hope someone can solve this issue for me, thx.Sub InsertNumRows()

    ActiveCell.EntireRow.Copy

    Dim Rng As Long

    Application.DisplayAlerts = False
    On Error Resume Next
    Rng = InputBox("Enter number of rows required.")
    On Error GoTo 0
    Application.DisplayAlerts = True

    If Rng = 0 Then
    MsgBox "You didn't specify a range!"
    Exit Sub

    Else
    Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(Rng, 0)).Select
    Selection.EntireRow.Insert Shift:=xlDown
    End If

    End Sub
  • To post as a guest, your comment is unpublished.
    devin · 7 months ago
    Love the code! how do i set the start range to skip the first row (Column Headers) and start on row 2?
    • To post as a guest, your comment is unpublished.
      skyyang · 7 months ago
      Hi, Devin,
      To skip the first header row, please apply the following VBA code:

      Sub insertrows()
      Dim I As Long
      Dim xCount As Integer
      LableNumber:
      xCount = Application.InputBox("Number of Rows", "Kutools for Excel", , , , , , 1)
      If xCount < 1 Then
      MsgBox "the entered number of rows is error ,please enter again", vbInformation, "Kutools for Excel"
      GoTo LableNumber
      End If
      For I = Range("A" & Rows.CountLarge).End(xlUp).Row To 2 Step -1
      Rows(I).Copy
      Rows(I).Resize(xCount).Insert
      Next
      Application.CutCopyMode = False
      End Sub

      Please try it, hope it can help you!