Copy row to new tab and duplicate based on quantity

GHOPF

New Member
Joined
Nov 6, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Not able to figure out based on similar posts, I don't have enough foundational macro knowledge.
Wanting to copy a row X times to another tab to print labels. If Onhand qty column D = 4 I want the row copied 4 times.
All rows on DATA1 tab starting on row 2 copied OnHand times to DATA2 tab starting on row 2. Simple but I can't get it.
Appreciate your help.
 

Attachments

  • ExcelHelp.JPG
    ExcelHelp.JPG
    104.6 KB · Views: 22

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Please, try this code.
VBA Code:
Sub ReplicateData()
 Dim c As Range
  For Each c In Sheets("DATA1").Range("A2:A" & Sheets("DATA1").Cells(Rows.Count, 1).End(3).Row)
   c.Resize(, 11).Copy Sheets("DATA2").Cells(Rows.Count, 1).End(3)(2).Resize(c.Offset(, 3).Value)
  Next c
End Sub
 
Upvote 0
Got it working and made my labels. I did have to paste values to DATA1 for it to work properly. DATA1 was references to the import tab. Thanks for posting this solution.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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