As per title, need help getting a VBA Macro code to work.
Can't post the actual data, but it's an excel table.
Column A__________B____________C_________________D
12345________Outlet Name_____Sales Area________Total Entries
Background: Spreadsheet has about 6 000 line items. The spreadsheet is specifying labels to be printed. Column A, B and C specifies the content for the label - ie: what must physically be printed on the label - . Column D specifies the quantity - ie: how many labels we need, how many times it should be printed.
The printer cannot read numbers so the label physically has to be reflected x amount of times so that it can print directly
The quantity specified in column D varies – it is not fixed at 50
So I need the row to be duplicated the amount specified in column D and this should be pasted into a new sheet. This needs to happen for each row. They should all be pasted directly underneath eachother.
The macro I currently have is:
Can I edit this to work for what I want to do?
Can't post the actual data, but it's an excel table.
Column A__________B____________C_________________D
12345________Outlet Name_____Sales Area________Total Entries
Background: Spreadsheet has about 6 000 line items. The spreadsheet is specifying labels to be printed. Column A, B and C specifies the content for the label - ie: what must physically be printed on the label - . Column D specifies the quantity - ie: how many labels we need, how many times it should be printed.
The printer cannot read numbers so the label physically has to be reflected x amount of times so that it can print directly
The quantity specified in column D varies – it is not fixed at 50
So I need the row to be duplicated the amount specified in column D and this should be pasted into a new sheet. This needs to happen for each row. They should all be pasted directly underneath eachother.
The macro I currently have is:
Code:
sub CopyData()
Dim lRow As Long
Dim RepeatFactor As Variant
lRow = 1
Do While (Cells(lRow, "A") <> "")
RepeatFactor = Cells(lRow, "B")
If ((RepeatFactor > 1) And IsNumeric(RepeatFactor)) Then
Range(Cells(lRow, "A"), Cells(lRow, "B")).Copy
Range(Cells(lRow + 1, "A"), Cells(lRow + RepeatFactor - 1, "B")).Select
Selection.Insert Shift:=xlDown
lRow = lRow + RepeatFactor - 1
End If
lRow = lRow + 1
Loop
End Sub
Can I edit this to work for what I want to do?
Last edited:

