Guinaba
Board Regular
- Joined
- Sep 19, 2018
- Messages
- 215
- Office Version
- 2016
- Platform
- Windows
Hi guys,
Wondering if someone could help me out, I have two arrays (below) and I'd like to combine both in a third one using the following logic:
Final Result:
Wondering if someone could help me out, I have two arrays (below) and I'd like to combine both in a third one using the following logic:
WkArr | UniqArr |
WkArr(1,1) = "Week Commencing Date" WkArr(1,2) = #2/01/2021# WkArr(1,3) = #9/01/2021# WkArr(1,4) = #16/01/2021# WkArr(1,5) = #23/01/2021# WkArr(1,6) = #30/01/2021# | UniqArr(0)(0) = "Brand" UniqArr(0)(1) = "SKUID" UniqArr(0)(2) = "Color" UniqArr(0)(3) = "Shape" UniqArr(1) UniqArr(1)(0) = "Tonto" UniqArr(1)(1) = "45678" UniqArr(1)(2) = "Green" UniqArr(1)(3) = "Square" UniqArr(2) UniqArr(2)(0) = "Benq" UniqArr(2)(1) = "45698" UniqArr(2)(2) = "Blue" UniqArr(2)(3) = "Oval" |
Final Result:
Week Commencing Date | Brand | SKUID | Color | Shape |
2/01/2021 | Tonto | 45678 | Green | Square |
9/01/2021 | Tonto | 45678 | Green | Square |
16/01/2021 | Tonto | 45678 | Green | Square |
23/01/2021 | Tonto | 45678 | Green | Square |
30/01/2021 | Tonto | 45678 | Green | Square |
2/01/2021 | Benq | 45698 | Blue | Oval |
9/01/2021 | Benq | 45698 | Blue | Oval |
16/01/2021 | Benq | 45698 | Blue | Oval |
23/01/2021 | Benq | 45698 | Blue | Oval |
30/01/2021 | Benq | 45698 | Blue | Oval |
VBA Code:
'Variant to hold the array element
Dim Wk_Start As Variant
'Array to keep combination between weeks and master data arrays
Dim ComboArr() As Variant
Dim r As Integer, c As Integer
'Loop through the entire array
For Each Wk_Start In WkArr
For r = 2 To UBound(UniqArr)
For c = 2 To UBound(UniqArr)
ComboArr(r, c) = UniqArr(r, c)
Next c
Next r
Next Wk_Start