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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,215,516
Messages
6,125,285
Members
449,218
Latest member
Excel Master

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