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 repeat rows a specified number of times based on another column in Excel?

Have you ever tried to repeat a row based on another column value as below screenshot shown? In this article, I will introduce the method on solving this job in Excel.
doc repeat rows based on column 1

Repeat rows based on another column value with VBA

Repeat rows with a fixed time by Kutools for Excel


Repeat rows based on another column value with VBA

Here I have a code which can quickly repeat the rows based on the last column values.

1. Press Alt + F11 keys to enable Microsoft Visual Basic for Applications window.

2. Click Insert > Module, then copy below code and paste it to the new Module script.

VBA: Repeat rows based on another column value

Sub CopyRow()
'UpdatebyExtendoffice20181011
Dim xRg As Range
Dim xCRg As Range
Dim xFNum As Integer
Dim xRN As Integer
On Error Resume Next
SelectRange:
xTxt = ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox("Select the number value", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub

If xRg.Columns.Count > 1 Then
    MsgBox "Please select single column!"
    GoTo SelectRange
End If
Application.ScreenUpdating = False
For xFNum = xRg.Count To 1 Step -1
Set xCRg = xRg.Item(xFNum)
    xRN = CInt(xCRg.Value)
    With Rows(xCRg.Row)
    .Copy
    .Resize(xRN).Insert
    End With
Next
Application.ScreenUpdating = True
End Sub

doc repeat rows based on column 2

3. Press F5 key, a dialog pops out, select the number list which the rows will be repeated based on.
doc repeat rows based on column 3

4. Click OK, the rows have been repeated based on the selected column value.
doc repeat rows based on column 1


Repeat rows with a fixed time by Kutools for Excel

If you want to repeat rows with a fixed time without inserting rows one by one, you can try to use the Insert Blank Rows & Columns and Fill Blank Cells utilities of Kutools for Excel to quickly handle this job.
doc repeat rows fixed time 1

Kutools for Excel, with more than 200 handy functions, makes your jobs easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

1. Select the data range you want to repeat rows, click Kutools > Insert > Insert Blank Rows & Columns. Then in the Insert Blank Rows & Columns dialog, check Blank rows option, then type 1 into Interval of textbox, and type the number you want to repeat rows in Rows textbox.
doc repeat rows fixed time 2

2. Click Ok, the blank rows have been inserted below each row.
doc repeat rows fixed time 3

3. Keep the range selected, click Kutools > Insert > Fill Blank Cells. In the Fill Blank Cells dialog, check Based on values and Down options.
doc repeat rows fixed time 4

4. Click Ok. Now the blank cells have been filled with above value.
doc repeat rows fixed time 5

Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!

You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free 45-day trial of Office Tab!

ot excel


Excel Productivity Tools

Kutools for Excel - The Best Office Productivity Tool

  • Brings 300 powerful advanced features to Excel, enable you to do smarter, faster and better.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Office Tab - brings tabbed interface to Office, make your work much easier.

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
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.

Be the first to comment.