Explode BOM lines in Excel to understand sales data by ship date

tanujath

New Member
Joined
Sep 17, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,
I am having a hard time exploding BOMs into BOM lines to explode my data by Ship date. Let me show an example below of what I am looking to do:

Table 1
SALES ORDER NO. ITEM NUMBER QTY SHIP DATE
100 KIT-1 10 9/31/2021
200 KIT-2 20 9/17/2021

Table 2
ITEM NUMBER BOM LINES QTY NEEDED
KIT-1 Item 1 1
KIT-1 Item 2 2
KIT-1 Item 3 5
KIT-2 Item 4 3
KIT-2 Item 5 1

Table 3
SALES ORDER NO. ITEM NUMBER BOM LINES QTY SHIPDATE
100 KIT-1 Item 1 10 9/31/2021
100 KIT-1 Item 2 20 9/31/2021
100 KIT-1 Item 3 50 9/31/2021
200 KIT-2 Item 4 60 9/17/2021
200 KIT-2 Item 5 20 9/17/2021

I have Table 1 and 2 available, need to explode Table 1 to Table 3 using Table 2. If anyone have any ideas I would love to try them out. VBA or formulas, anything is fine.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Welcome to the MrExcel Message Board!

Let's see if I got the idea correctly.
You have 3 sheets Sheet1 (Table1), Sheet2 (Table2) and Sheet3 (Table3).
All headings in row 1 and data start in cell A2. Check the images:
Dante Amor
ABCD
1SALES ORDER NO.ITEM NUMBERQTYSHIP DATE
2100KIT-11030/09/2021
3200KIT-22017/09/2021
Sheet1

Dante Amor
ABCD
1ITEM NUMBERNUMBERBOM LINESQTY NEEDED
2KIT-1Item11
3KIT-1Item22
4KIT-1Item35
5KIT-2Item43
6KIT-2Item51
Sheet2

Dante Amor
ABCDEF
1SALES ORDER NO.ITEM NUMBERNUMBERBOM LINESQTYSHIP DATE
2100KIT-1Item11030/09/2021
3100KIT-1Item22030/09/2021
4100KIT-1Item35030/09/2021
5200KIT-2Item46017/09/2021
6200KIT-2Item52017/09/2021
Sheet3

Try this macro:
VBA Code:
Sub Explode_BOM_Lines()
  Dim a As Variant, b As Variant, c As Variant
  Dim dic As Object
  Dim i As Long
 
  a = Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("D" & Rows.Count).End(3)).Value
  b = Sheets("Sheet2").Range("A2", Sheets("Sheet2").Range("D" & Rows.Count).End(3)).Value
  ReDim c(1 To UBound(b, 1), 1 To 6)
  Set dic = CreateObject("Scripting.Dictionary")
 
  For i = 1 To UBound(a, 1)
    dic(a(i, 2)) = a(i, 1) & "|" & a(i, 3) & "|" & a(i, 4)
  Next
 
  For i = 1 To UBound(b, 1)
    c(i, 1) = Split(dic(b(i, 1)), "|")(0)
    c(i, 2) = b(i, 1)
    c(i, 3) = b(i, 2)
    c(i, 4) = b(i, 3)
    c(i, 5) = Split(dic(b(i, 1)), "|")(1) * b(i, 4)
    c(i, 6) = Split(dic(b(i, 1)), "|")(2)
  Next
 
  Sheets("Sheet3").Range("A2").Resize(UBound(b, 1), 6).Value = c
End Sub
 
Upvote 0
Solution
Hi Dante Amor,

Thank you, the code works like magic!!

I have a doubt though, the tables I provided above are examples. My actual tables have these dimensions:

table 1:
Columns A to AD
Rows: 20,000

Table 2:
Columns A to F
Rows: 1500

Since Table 1 is sales data, the item numbers or kits can repeat as well. Could you provide a code for this?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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