And then press F5 key to run this code, and a prompt box is popped out to remind you to enter the number of times that you want to duplicate for each record, see screenshot:Ĥ. MsgBox "the entered number of rows is error ,please enter again", vbInformation, "Kutools for Excel"įor I = Range("A" & Rows.CountLarge).End(xlUp).Row To 2 Step -1ģ. VBA code: Duplicate each row multiple times: Sub insertrows() Hold down the ALT + F11 keys, then it opens the Microsoft Visual Basic for Applications window. To duplicate each rows multiple times in a range, you can apply the following VBA code, please do as below:ġ.
Download and free trial Now!Ĭopy and insert each row multiple times with VBA code Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. But, with Kutools for Excel's Duplicate Rows / columns based on cell value feature, you can solve this problem with ease. Normally, there is not a good method for copying and inserting rows multiple times except dealing with manually copy and insert. Then click OK button, and three new copied rows have been inserted below the selected row, see screenshot:Ĭopy and insert each row multiple times based on a specific number easily After pasting the code, please press F5 key to run this code, and a prompt box is popped out to remind you to enter the number of times that you want to duplicate, see screenshot:Ĥ. Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(xCount, 0)).EntireRow.Insert Shift:=xlDownģ. MsgBox "the entered number of rows is error, please enter again", vbInformation, "Kutools for Excel" XCount = Application.InputBox("Number of Rows", "Kutools for Excel",, ,, ,, 1) VBA code: Duplicate one specific row multiple times: Sub test()
Click Insert > Module, and paste the following code in the Module Window. 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.Ģ. If you want to duplicate only one specific row x times, the following VBA code may help you, please do as this:ġ.
How to copy and insert row multiple times or duplicate the row x times in Excel?