Convert single PO line item to multiple rows based on quantity ordered

MattsDad

New Member
Joined
Sep 1, 2010
Messages
14
Hi. I'm trying to build a process to aid our warehouse in printing barcode labels for inventory received. Currently someone has to take the PO/receiving document and manually enter the part number into a text file on a separate row for each individual piece that is received so our barcode printer can print the correct label to attach to our product.

For example, on a basic receiving document we receive 3 units of Item A and 1 unit of Item B that shows like this:
Item Qty
A 3
B 1

The warehouse worker then enters the data like this in the text file that will be printed:
A
A
A
B

The question is, can i do this in Excel 2003 on an XP box? We can easily import this data from the PO/receiving report to Excel, which I have done. I'm trying to figure out how to get Excel to create an output file either directly to a text file or to another tab in the workbook but I don't know how to instruct Excel to use one line of input as a source for more than one line of output.

I've spent several hours trying formulas to no avail. I don't know enough about VBA code to be able to write this myself. Any help you can give will be greatly appreciated.
 
Welcome to the MrExcel board!

I'm not really sure what you are asking.

BTW, best not to fully quote long posts as it makes the thread harder to read/navigate. If you want to quote, just quote small, relevant parts only.

thanks peter for your quick answer i just need to know how i can make this VBA code live on excel 2016 as mentioned above and sorry for long quote :)
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
thanks peter for your quick answer i just need to know how i can make this VBA code live on excel 2016 ..
The code works for me on Excel 2016 as it is. What problems are you having?
Have you tried it on a fresh sheet with the sample data as shown in columns A:D of post 6? Does it work for you for that data?
 
Upvote 0
its worked but im trying to make it on my data so can i give you it and make it for me please ?
 
Upvote 0
its worked but im trying to make it on my data so can i give you it and make it for me please ?
You are welcome to post a small set of your dummy data and expected results so we can see what you have and what you are trying to achieve. My signature block below has a link for how to do that.
 
Upvote 0
You are welcome to post a small set of your dummy data and expected results so we can see what you have and what you are trying to achieve. My signature block below has a link for how to do that.

thanks peter so my orders is,

ORDER_NUMBERSKUDESCRIPTIONORDERED_QUANTITYDELIVERY_METHOD
5004811112170313iPhone 7 32GB Matte Black Local2MovEx
5004828112170379IPhone 6 32GB Grey LTE/ Local2ELT Driver
5004845112170387iPhone 8 Plus 64GB Space Grey /Local2Sales
5004714112170402Iphone X 256 GB Silver /Local2NokSmart
5004710112170404IPhone X 256 GB Space Gray/Local2Union Courier

<tbody>
</tbody>

i need to distributed into that example,

OrderSKUItem DescriptionQTYSerial Numbers18 DigitSR NumberReleased ByDelivery MethodOrder Status
5004811112170313iPhone 7 32GB Matte Black Local1MovEx
112170313iPhone 7 32GB Matte Black Local1MovEx
5004828112170379IPhone 6 32GB Grey LTE/ Local1ELT Driver
112170379IPhone 6 32GB Grey LTE/ Local1ELT Driver
5004845112170387iPhone 8 Plus 64GB Space Grey /Local1Sales
112170387iPhone 8 Plus 64GB Space Grey /Local1Sales
5004714112170402Iphone X 256 GB Silver /Local1NokSmart
112170402Iphone X 256 GB Silver /Local1NokSmart
5004710112170404IPhone X 256 GB Space Gray/Local1Union Courier
112170404IPhone X 256 GB Space Gray/Local1Union Courier

<tbody>
</tbody>


<tbody>
</tbody>
 
Upvote 0
Welcome to the MrExcel board!

My best guess, without seeing a small set of sample data and expected results is as follows.
Test in a copy of your workbook.

If it is not what you want, please give a small set of sample data and expected results together with further explanation. My signature block below has further info about how to do screen shots.

Rich (BB code):
Sub Rearrange()
  Dim a, b
  Dim i As Long, j As Long, k As Long, z As Long
  
  With Range("A2", Range("D" & Rows.Count).End(xlUp))
    a = .Value
    ReDim b(1 To 4, 0 To 0)
    For i = 1 To UBound(a)
      ReDim Preserve b(1 To 4, 1 To UBound(b, 2) + a(i, 4))
      For j = 1 To a(i, 4)
        z = z + 1
        For k = 1 To 4
          b(k, z) = a(i, k)
        Next k
      Next j
    Next i
    .Offset(, .Columns.Count + 1).Resize(z).Value = Application.Transpose(b)
  End With
End Sub


around this code please can you tell me how can i make this Red Function?
thank you
 
Last edited by a moderator:
Upvote 0
Try this code in a copy of your workbook.
Code:
Sub Rearrange()
  Dim a, b
  Dim i As Long, j As Long, k As Long, z As Long, rws As Long, cols As Long
  
  With Range("A2", Range("E" & Rows.Count).End(xlUp))
    a = .Value
    rws = Application.WorksheetFunction.Sum(.Columns(4))
    cols = UBound(a, 2)
    ReDim b(1 To rws, 1 To cols)
    For i = 1 To UBound(a)
      For k = 1 To a(i, 4)
        z = z + 1
        For j = 1 To cols
            b(z, j) = a(i, j)
        Next j
      Next k
    Next i
    With .Offset(, .Columns.Count + 1).Resize(rws)
      .Value = b
      .Columns(5).Resize(, 4).Insert
      .Cells(0, 1).Resize(, 10).Value = Split("Order|SKU|Item Description|QTY|Serial Numbers|18 Digit|SR Number|Released By|Delivery Method|Order Status", "|")
      .Columns(4).Value = 1
      .CurrentRegion.Columns.AutoFit
    End With
  End With
End Sub
 
Upvote 0
How can i post it on my workbook ? i put it as a module 1 or what ?
 
Upvote 0
How can i post it on my workbook ? i put it as a module 1 or what ?
Hmm, in post 13 you said the previous code "worked" so I assumed you knew how to implement the code. :)

To implement ..
1. With your workbook active press Alt+F11 to bring up the vba window.
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Press Alt+F8 to bring up the Macro dialog
6. Select the macro & click ‘Run’
7. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)
 
Upvote 0
many thanks for your usual support peter you're really polite man and im sorry for disturbing you many times so ive another question can i do this functions with macro codes ? for example with offset function with any formulas ? :)
 
Upvote 0

Forum statistics

Threads
1,215,580
Messages
6,125,652
Members
449,245
Latest member
PatrickL

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