Duplicating rows based on data in column

cuallaidh

New Member
Joined
Jun 6, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. MacOS
I have a spreadsheet that looks like this:

UPCProductQtyPrice
123456789098Product 1109.99
098765432123Product 227.00
456789098765Product 311.99

What I need to do is create a new worksheet that has each row copied the number of times in the Qty column so Product 1 should be copied 10 times, product 2 twice and Product 3 just the once.

I have tried looking at other scripts on here for similar solutions, but cannot seem to get any of them to work right. I am using Exel v16 on Mac OS.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
VBA Code:
Sub t()
Dim i As Long
With ActiveSheet
    For i = .Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        Rows(i).Copy
        Rows(i).Offset(1).Resize(.Cells(i, "C").Value).EntireRow.Insert
    Next
End With
End Sub
 
Upvote 0
Creat a helper column in A:A, enter formula in G2, drag to the right and down, until it returns "".
Cell Formulas
RangeFormula
G2:J17G2=IF(ROW(A1)>SUM($D:$D),"",IFERROR(VLOOKUP(ROW(A1),$A:$E,COLUMN(B1),),G3))
A2:A4A2=SUM(D$2:D2)
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top