How to Repeat Multiple Rows in Excel (4 Effective Ways)

This article illustrates how to repeat multiple rows in Excel. If you are working with datasets, then typing the same data, again and again, is both tiresome and time-consuming. Fortunately, Excel allows us to repeat the same data very quickly. In this article, we will discuss how to repeat multiple rows in 4 different ways in Excel. Follow along to be able to do that.


How to Repeat Multiple Rows in Excel: 4 Effective Ways

Here are the 4 ways you can repeat multiple rows in Excel.

1. Repeat Multiple Rows Using Fill Handle Tool

You can use the Fill Handle tool to quickly repeat multiple rows in Excel.

📌 Steps:

  • Assume you have the following dataset. You need to repeat rows 5 to 7.

  • Then, select the rows and drag the Fill Handle icon below. After that, you will get the desired results.

repeat multiple rows in excel

Read More: How to Repeat Rows in Excel Based on Cell Value


2. Copy Multiple Rows Using Formula

Alternatively, you can use a custom formula to do that.

📌 Steps:

  • First, apply the following formula in cell B8. Then, drag the Fill Handle icon to the right. Now the first row is repeated once.
=IF(ISBLANK(INDIRECT("Formula!B"&ROW(B5))),INDIRECT("Formula!B"&(ROWS($B$5:B5)-(COUNTA(Formula!B:B)-2))),Formula!B5)

repeat multiple rows in excel

  • Next, drag the Fill Handle down to repeat the rows as many times as you want.

How Does the Formula Work?

➤ ROW(B5)
The ROW function returns the row number of a cell.
Output: {5}

➤ ROWS($B$5:B5)
The ROWS function returns the number of rows in a reference or array.
Output: 1
The output will change as you drag the formula down.

➤ COUNTA(Formula!B:B)
The COUNTA function counts the number of non-blank cells in a range.
Output: 6

➤ INDIRECT(“Formula!B”&ROW(B5))
The INDIRECT function returns the reference specified by a text string.
Output: {“Amelia Claire”}

➤ ISBLANK(INDIRECT(“Formula!B”&ROW(B5)))
The ISBLANK function checks whether a reference is to an empty cell and returns TRUE or FALSE.
Output: {FALSE}

➤ IF(ISBLANK(INDIRECT(“Formula!B”&ROW(B5))),INDIRECT(“Formula!B”&(ROWS($B$5:B5)-(COUNTA(Formula!B:B)-2))),Formula!B5)
The IF function checks whether a condition is met, and returns one value if TRUE and, another value if FALSE.
Output: {“Amelia Claire”}

Read More: How to Repeat Formula for Each Row in Excel


3. Repeat Header Rows While Printing

Now we will discuss a different case of repeating multiple cells in Excel.

Assume you have a larger dataset as follows that can’t be printed on a single page.

When you print the sheet, the first page will be printed as follows.

But the next pages will be printed without any header cells.

You can make Excel repeat the multiple header rows at the top of every page while printing the sheet.

📌 Steps:

  • First, go to the Page Layout tab and click on Print Titles. You will find that in the Page Setup group.

  • Then make sure you are in the Sheet tab in the Page Setup dialog box. Next, click on the upward arrow in the Rows to repeat at top: field to select the header rows at the top of each page. Click OK after that.

repeat multiple rows in excel

  • Now, excel will repeat the selected multiple header rows at the top of each page while printing.

Read More: How to Repeat Rows in Excel When Printing


4. Repeat Multiple Rows Using VBA

Finally, we will discuss how to repeat multiple rows for a specific number of times with VBA in Excel.

📌 Steps:

  • Consider the first example again. Here, first, you need to enter the numbers by which you want to repeat the rows in a new adjacent column as shown below.

  • Then press ALT+F11 to open the VBA window. Next, select Insert >> Module. After that, a blank module will be created.

  • Now copy the following code.
Sub RepeatMultipleRows()
Dim rng, crng As Range
Dim fnum, rn As Integer
On Error Resume Next
SelectRange:
xTxt = ActiveWindow.RangeSelection.Address
Set rng = Application.InputBox("Select the repeating number", _
"ExcelDemy.com", xTxt, , , , , 8)
If rng Is Nothing Then Exit Sub
If rng.Columns.Count > 1 Then
MsgBox "Select single column only!"
GoTo SelectRange
End If
Application.ScreenUpdating = False
For fnum = rng.Count To 1 Step -1
Set crng = rng.Item(fnum)
rn = CInt(crng.Value)
With Rows(crng.Row)
.Copy
.Resize(rn).Insert
End With
Next
Application.ScreenUpdating = True
End Sub
  • Next, paste the copied code onto the blank module as below.

repeat multiple rows in excel

  • After that, press F5 to run the code.

  • Then, select the range containing the specific numbers and click OK.

  • Finally, you will see each row is being repeated the specified number of times below it.

repeat multiple rows in excel

🔎 VBA Code Explanation

Sub RepeatMultipleRows()
We will write the code inside this subject procedure.

Dim rng, crng As Range
Dim fnum, rn As Integer
Declaring necessary variables.

On Error Resume Next
Force VBA to ignore errors.

SelectRange:
xTxt = ActiveWindow.RangeSelection.Address
Set rng = Application.InputBox(“Select the repeating number”, _
“ExcelDemy.com”, xTxt, , , , , 8)
Takes user input.

If rng Is Nothing Then Exit Sub
If the user enters nothing then the subject ends.

If rng.Columns.Count > 1 Then
MsgBox “Select single column only!”
If the user selects more than one column, VBA shows a warning.

GoTo SelectRange
Then, VBA repeats the earlier process.

Application.ScreenUpdating = False
Forces VBA to run in the background to work faster.

For fnum = rng.Count To 1 Step -1
Set crng = rng.Item(fnum)
rn = CInt(crng.Value)
With Rows(crng.Row)
.Copy
.Resize(rn).Insert
End With
Next
Copies the rows the number of times specified by the rn variable.

Application.ScreenUpdating = True
Resets screen updating.


Things to Remember

  • You can copy the repeated rows and paste them as values if required. But, don’t forget to copy the formula before doing that.
  • Back up your data before running the VBA code.
  • You need to save the file as a macro-enabled workbook to avoid losing the code.

Download Practice Workbook

You can download the practice workbook from the download button below.


Conclusion

Now you know how to repeat multiple rows in Excel in 4 different ways. Do you have any further queries or suggestions? Please let us know in the comment section below.


Related Articles


<< Go Back to Repeat in Excel | Excel Cell Format | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Shamim Reza
Md. Shamim Reza

Md. Shamim Reza, a marine engineer with expertise in Excel and a fervent interest in VBA programming, sees programming as a time-saving tool for data manipulation, file handling, and internet interaction. His diverse skill set encompasses Rhino3D, Maxsurf C++, AutoCAD, Deep Neural Networks, and Machine Learning. He holds a B.Sc in Naval Architecture & Marine Engineering from BUET and has transitioned into a content developer role, generating technical content focused on Excel and VBA. Beyond his professional pursuits,... Read Full Bio

6 Comments
  1. After press F5 the box with “run” not appear straight to key in the number of repeat.
    When i highlight the column of repeat number it not show something like $A$1:$A$22

    • Hello KHOR,
      After pressing F5 I am having the input box with the help of which I could select the range of repeated numbers easily and perform the row repetition. But if this shortcut key is not working for you then you can try the following technique.
      • Press the Run button above your code.

      1

      Then, the input box will appear.
      • Go to the main sheet and select your range containing numbers up to which you want to repeat.

      2

      • After pressing OK, you will get the work done.

      3

      Hope this way will help you solve your problem.

      Thanking You
      Tanjima Hossain
      ExcelDemy

  2. Hi Shameem,
    Thank you so much for the code and I wanted to mention series of numbers for every cell. For example I have copied 50 columns by using the code and need to mention 1 to 50 numbers in each cell. Do we have any possibility to extend the code? If yes, please help me.

    • Reply Lutfor Rahman Shimanto
      Lutfor Rahman Shimanto Feb 5, 2024 at 6:15 PM

      Hello BHARATH L

      Thanks for your nice words. Your appreciation means a lot to us. You wanted to mention a series of numbers for every copied row. In your words, if you have copied 50 columns using the code, you need to mention 1 to 50 numbers in each row.

      I am delighted to inform you that I have developed an Excel VBA sub-procedure to fulfil your requirements. I have modified the existing article code and made it an advanced version.

      OUTPUT OVERVIEW:

      Advanced Excel VBA Code:

      
      Sub RepeatMultipleRows()
          
          Dim rng As Range, crng As Range
          Dim fnum As Integer, rn As Integer
          Dim i As Integer
          On Error Resume Next
          
      SelectRange:
          xTxt = ActiveWindow.RangeSelection.Address
          Set rng = Application.InputBox("Select the repeating number", "ExcelDemy.com", xTxt, , , , , 8)
          
          If rng Is Nothing Then Exit Sub
          If rng.Columns.Count > 1 Then
              MsgBox "Select single column only!"
              GoTo SelectRange
          End If
          
          Application.ScreenUpdating = False
          
          For fnum = rng.Count To 1 Step -1
              Set crng = rng.Item(fnum)
              rn = crng.Value
              For i = 1 To rn
                  crng.Offset(0, 1).Resize(1, 1).Value = i
                  crng.EntireRow.Copy
                  crng.Offset(1).EntireRow.Insert
              Next i
              crng.Offset(0, 1).Value = crng.Offset(0, 0).Value + 1
              crng.Offset(0, 1).Font.Bold = True
          Next
          
          Application.CutCopyMode = False
          Application.ScreenUpdating = True
      
      End Sub
      

      Hopefully, the code will fulfil your goal. Good luck.

      Regards
      Lutfor Rahman Shimanto
      Excel & VBA Developer
      ExcelDemy

  3. Hello LUTFOR RAHMAN SHIMANTO,

    Thank you for the above and it is working awesome.

    Best Regards
    Bharath L

    • Dear Bharath L,

      You are most welcome. We are glad that our solution worked for you.

      Regards
      ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo