How to Repeat Cell Value X Times in Excel?


Excel is a strong programme with a variety of functions that make manipulating and analysing data simple. Repeating a certain cell value several times in a column is a typical need. This tutorial will walk you through the step-by-step method of efficiently accomplishing this work, regardless of whether you want to generate test data, develop templates, or simply replicate data.

Whether you're a novice or a seasoned Excel user, you'll find this tutorial to be simple to read and full of helpful advice. Make sure you have a basic understanding of Excel's interface and features before we start. Since the techniques we go through work with the majority of versions of Excel, you can utilise any version.

Repeat Cell Value X Times

Here we will first create a VBA module and then select the range of data to complete the task. So let us see a simple process to know how you can repeat a cell value x time in Excel.

Step 1

Consider an Excel sheet where you have a list of cells with times to repeat, 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 CopyData()
Dim Rng As Range
Dim InputRng As Range, OutRng As Range
xTitleId = "Repeat Value X Times"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Output Cell (single cell):", xTitleId, Type:=8)
Set OutRng = OutRng.Range("A1")
For Each Rng In InputRng.Rows
   xValue = Rng.Range("A1").Value
   xNum = Rng.Range("B1").Value
   OutRng.Resize(xNum, 1).Value = xValue
   Set OutRng = OutRng.Offset(xNum, 0)
Next
End Sub

Step 3

Then click F5 to run the module. Then select the range of cells and click OK.

F5 > Select Cells > OK

Step 4

Then select a single destination cell and click OK to complete the task.

Select Cell > OK.

This is how you can repeat a cell value x time in Excel.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can repeat a cell value x time in Excel to highlight a particular set of data.

Updated on: 27-Sep-2023

357 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements