Macro Help - combining two or more lists of data in a loop

jlhop66

New Member
Joined
Apr 24, 2014
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I am new to Macros, and I am learning new was to make repetitive tasks easier.


Here is what I need help with. I have 3 list of data and I need to combine them.


  1. Item list (5 to 100 items in a list)
  2. Quantity list
  3. Store list (2 to 10 stores)

For every item in my list, I need to add the list of stores to distribute to, and the quantity needed.

Example of order sheet

Stores
Items 7422707159
100122222
200211111
300344444
400466666
500533333
600688888


I need a macro to convert the order array list into column form such as Items “A”, Store “B” and Qty “C”

ItemQTYStore
1001274
1001222
1001270
1001271
1001259
2002174
2002122
2002170
2002171
2002159
3003474
3003422
3003470
3003471
3003459

I have been trying for 3 weeks diffrent loop combinations, and I just cannot figure this out.

Please Help
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Returned in Columns I:K as per below. Assumed your raw data is in A:F as per below


Code:
Sub Transpe()
Dim iData As Variant
Dim iCoun As Integer
Dim iRow  As Integer
Dim fData As Variant
iRow = Range("A" & Rows.Count).End(xlUp).Row
iData = Range("A2:F" & iRow).Value
ReDim fData(1 To (UBound(iData) - 1) * 5, 1 To 3)
For iCoun = LBound(fData, 1) To UBound(fData, 1)
    fData(iCoun, 1) = iData(Int((iCoun - 1) / 5) + 2, 1)
    fData(iCoun, 2) = iData(Int((iCoun - 1) / 5) + 2, 2 + ((iCoun - 1) Mod 5))
    fData(iCoun, 3) = iData(1, 2 + ((iCoun - 1) Mod 5))
Next iCoun
Range("I1").Resize(, 3).Value = Array("Item", "QTY", "Store")
Range("I2").Resize(UBound(fData, 1), 3).Value = fData
End Sub



Excel 2012
ABCDEFGHIJK
1StoresItemQTYStore
2Items74227071591001274
31001222221001222
42002111111001270
53003444441001271
64004666661001259
75005333332002174
86006888882002122
92002170
102002171
112002159
123003474
133003422
143003470
153003471
163003459
174004674
184004622
194004670
204004671
214004659
225005374
235005322
245005370
255005371
265005359
276006874
286006822
296006870
306006871
316006859

<tbody>
</tbody>
Sheet2
 
Last edited:
Upvote 0
Thank you very much. after I walked through the steps a few times, it made sence what was happening. I appriciate the help, the tool works great.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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