Reorient a table that has 2D arrays

Alex0013

Board Regular
Joined
Jul 23, 2014
Messages
158
Office Version
  1. 365
Platform
  1. Windows
Hello,
I need some help creating a VBA sub that will reorient a table that has 2D arrays from a table, to rows. Essentially the result needs to have a header row (H in column A, Team ID in B, and Team Name in C.) Then, each cell in the table is a 2D array. I need the result to make a row for each pair, using the row and column headers (M in column A, Team ID in B, Field ID in C, Model ID in D, Array[1] in E, and Array[2] in F.) For each team, it needs to loop until the end of the columns (in the end I'll probably have 5+ models), and loop through all the teams (I'll probably have 80+ teams). The result can be posted to another tab, location isn't a big deal.


I've never worked with 2D arrays and I'm not sure how to lay out this in VBA. I would greatly appreciate help with this.


Thanks!

(PS, Sorry for the screenshots...I couldn't get HTMLMaker to work today...I'll have to fix it later. I posted the screenshots and text)

Model1Model1Model1Model2Model2Model2
RankAccountCityRankAccountState
T_LIONDetroit Lions2,WSALES,W;MARGIN,R;INCOME,RDetroit,W1,WSALES,R;MARGIN,W;INCOME,RMichigan,W
T_PACKERSGreen Bay Packers1,W
SALES,W;MARGIN,R;INCOME,RGreen Bay,W2,WSALES,R;MARGIN,W;INCOME,RWisconsin,W
T_DOLPHINSMiami Dolphins3,WSALES,W;MARGIN,W;INCOME,RMiami,W3,WSALES,R;MARGIN,W;INCOME,RFlorida,W

<tbody>
</tbody>



HT_LIONDetoit Lions
MT_LIONRankModel12W
MT_LIONAccountModel1SALESW
MT_LIONAccount
Model1MARGINR
MT_LIONAccountModel1INCOMER
MT_LIONCityModel1DetroitW
MT_LIONRankModel21W
MT_LIONAccountModel2SALESR
MT_LIONAccountModel2MARGINW
MT_LIONAccountModel2INCOMER
MT_LIONStateModel2MichiganW
HT_PACKERSGreen Bay Packers
MT_PACKERSRankModel11W
MT_PACKERSAccountModel1SALESW
MT_PACKERSAccountModel1MARGINR
MT_PACKERSAccountModel1INCOMER
MT_PACKERSCityModel1Green BayW
MT_PACKERSRankModel21W
MT_PACKERSAccountModel2SALESR
MT_PACKERSAccountModel2MARGINW
MT_PACKERSAccountModel2INCOMER
MT_PACKERSStateModel2WisconsinW
HT_DOLPHINSMiami Dolphins
MT_DOLPHINSRankModel13W
MT_DOLPHINSAccountModel1SALESW
MT_DOLPHINSAccountModel1MARGINW
MT_DOLPHINSAccountModel1INCOMER
MT_DOLPHINSCityModel1MiamiW
MT_DOLPHINSRankModel23W
MT_DOLPHINSAccountModel2SALESR
MT_DOLPHINSAccountModel2MARGINW
MT_DOLPHINSAccountModel2INCOMER
MT_DOLPHINSStateModel2FloridaW

<tbody>
</tbody>
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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