
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Repeat Rows a Specified Number of Times Based on Another Column in Excel
When working with huge datasets or when you need to expand and organise your data, this effective technique lets you duplicate rows based on the value of a specific column, saving you time and effort.
In this article, we'll show you step-by-step how to accomplish this work effectively utilising Excel's built-in functions and features. This technique will be quite helpful in optimising your productivity, regardless of whether you are working with sales data, survey results, or any other type of information that requires row repetition.
Repeat Rows a Specified Number of Times Based on Another Column
Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to know how you can repeat rows a specified number of times based on another column in Excel.
Step 1
Consider an Excel sheet where the data in the sheet is similar to the below image.

First, right-click on the sheet name and select View Code to open the VBA application.
Right-click > View Code.
Step 2
Then click on Insert and select Module, then copy the below code into the text box.
Insert > Module > Copy.
Code
Sub CopyRow() 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", "Repeat Specified Times", 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

Step 3
Then click F5 to run the module. Then select the range of cells and click OK to complete the task.
F5 > Select Cells > OK

This is how you can repeat rows a specified number of times based on a column in Excel.
Conclusion
In this tutorial, we have used a simple example to demonstrate how you can repeat rows a specified number of times based on another column in Excel to highlight a particular set of data.