Excel - Split data into several rows

March 2017



Issue


I would like to split a row of data into several rows of same data in MS Excel. For example, I have an item with standard packing size of 100pcs per box. My customer places an order for 1,000pcs. I would like to have this order item repeated 10 times in the worksheet with each row having 100pcs as the box quantity.

Solution


First select the entire row you would like to repeat.

Run the following code:

Sub RepeatRow()  
Dim iRow As Integer  
Dim x As Integer  
Dim y As Integer  

iRow = ActiveCell.Row  
x = InputBox("Number of times you want to display the selected row:")  
y = 1  

Do  
Rows(iRow).Copy  
Selection.Insert Shift:=xlDown  
y = y + 1  
Loop Until y = x  

Application.CutCopyMode = False  

End Sub
  • Running the code will let you input the number of times you want to see the row repeated.
  • In your case select the row with 100pcs in it, run the code, input 10 and you will see that your one row turned into 10 rows.


Thanks to Trowa for this tip.

Related


Published by jak58.
This document, titled "Excel - Split data into several rows ," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).