Copy a list of Numbers based on row header (matrix table)

KasperSSI

New Member
Joined
Nov 28, 2019
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hi,

Is there a formula or VBA solution for this following issue:

In coloumn A2:A30 i have a list of Account Numbers and In B1:M1 i have the months.


I want to make an import sheet - but this requires that the format is changed to
A2:A30 = accounts and B2:B30 = January
A31:A61 = same accounts and B31:B61 = February. And so forth until there is no more headers In row1.

I am thinking VBA might be the soloution - but dont know how to go about it.

Any sugestions?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Something along these lines?

Excel Formula:
=HSTACK(TOCOL(IF(SEQUENCE(,12),A2:A30),,TRUE),TOCOL(IF(SEQUENCE(ROWS(A2:A30)),B1:M1),,TRUE))
 
Upvote 0
Solution
.. or could it be one of these?

For the future, so we do not have to guess so much what you mean please consider usingXL2BB for providing sample data & expected results to make it easier for helpers to understand just what you have & where it is and also what you want & where it is to be.
(If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

KasperSSI.xlsm
ABCDEFGHIJKLMNOPQRST
1JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberGuess 1Guess 2
2Ac 197255245423346698963663Ac 197Ac 1January97
3Ac 21382556364558246691570Ac 21Ac 2January1
4Ac 35962524545443816633418Ac 359Ac 3January59
5Ac 4116722811127519618691769Ac 411Ac 4January11
6Ac 560995774731774405470614Ac 560Ac 5January60
7Ac 661844064676671264416669Ac 661Ac 6January61
8Ac 755552272086473565673390Ac 755Ac 7January55
9Ac 8355930942224455036946389Ac 835Ac 8January35
10Ac 971569791671847823776428Ac 971Ac 9January71
11Ac 1028812017737281446904495Ac 1028Ac 10January28
12Ac 1166489935945078775692178Ac 1166Ac 11January66
13Ac 12802933703560294812666519Ac 1280Ac 12January80
14Ac 1371249819604967925384681Ac 1371Ac 13January71
15Ac 1494792866786588334308339Ac 1494Ac 14January94
16Ac 156959951634611130201976Ac 156Ac 15January6
17Ac 161958846693754632598223Ac 1619Ac 16January19
18Ac 1755985159126037196524320Ac 1755Ac 17January55
19Ac 1820298827505421892239931Ac 1820Ac 18January20
20Ac 1919478202940952285606661Ac 1919Ac 19January19
21Ac 20839642553291164819593736Ac 2083Ac 20January83
22Ac 214014727798764559718249Ac 2140Ac 21January40
23Ac 22185092709088151943541826Ac 2218Ac 22January18
24Ac 23546277383141469931207367Ac 2354Ac 23January54
25Ac 24934568627644955521877Ac 2493Ac 24January93
26Ac 25343479263266406180326990Ac 2534Ac 25January34
27Ac 26583170618718194876972Ac 2658Ac 26January58
28Ac 277575919376526093491858Ac 2775Ac 27January75
29Ac 28427592221556484641953061Ac 2842Ac 28January42
30Ac 296349313584079274620880Ac 2963Ac 29January63
31Ac 125Ac 1February25
32Ac 238Ac 2February38
33Ac 36Ac 3February6
34Ac 467Ac 4February67
35Ac 599Ac 5February99
Sheet1
Cell Formulas
RangeFormula
O2:P349O2=HSTACK(TOCOL(IF(SEQUENCE(,12),A2:A30),,1),TOCOL(B2:M30,,1))
R2:T349R2=TEXTSPLIT(TEXTJOIN(":",,TOCOL(IF(SEQUENCE(,12),A2:A30&"|"&B1:M1&"|"&B2:M30),,1)),"|",":")
Dynamic array formulas.
 
Upvote 0
.. or could it be one of these?

For the future, so we do not have to guess so much what you mean please consider usingXL2BB for providing sample data & expected results to make it easier for helpers to understand just what you have & where it is and also what you want & where it is to be.
(If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

KasperSSI.xlsm
ABCDEFGHIJKLMNOPQRST
1JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecemberGuess 1Guess 2
2Ac 197255245423346698963663Ac 197Ac 1January97
3Ac 21382556364558246691570Ac 21Ac 2January1
4Ac 35962524545443816633418Ac 359Ac 3January59
5Ac 4116722811127519618691769Ac 411Ac 4January11
6Ac 560995774731774405470614Ac 560Ac 5January60
7Ac 661844064676671264416669Ac 661Ac 6January61
8Ac 755552272086473565673390Ac 755Ac 7January55
9Ac 8355930942224455036946389Ac 835Ac 8January35
10Ac 971569791671847823776428Ac 971Ac 9January71
11Ac 1028812017737281446904495Ac 1028Ac 10January28
12Ac 1166489935945078775692178Ac 1166Ac 11January66
13Ac 12802933703560294812666519Ac 1280Ac 12January80
14Ac 1371249819604967925384681Ac 1371Ac 13January71
15Ac 1494792866786588334308339Ac 1494Ac 14January94
16Ac 156959951634611130201976Ac 156Ac 15January6
17Ac 161958846693754632598223Ac 1619Ac 16January19
18Ac 1755985159126037196524320Ac 1755Ac 17January55
19Ac 1820298827505421892239931Ac 1820Ac 18January20
20Ac 1919478202940952285606661Ac 1919Ac 19January19
21Ac 20839642553291164819593736Ac 2083Ac 20January83
22Ac 214014727798764559718249Ac 2140Ac 21January40
23Ac 22185092709088151943541826Ac 2218Ac 22January18
24Ac 23546277383141469931207367Ac 2354Ac 23January54
25Ac 24934568627644955521877Ac 2493Ac 24January93
26Ac 25343479263266406180326990Ac 2534Ac 25January34
27Ac 26583170618718194876972Ac 2658Ac 26January58
28Ac 277575919376526093491858Ac 2775Ac 27January75
29Ac 28427592221556484641953061Ac 2842Ac 28January42
30Ac 296349313584079274620880Ac 2963Ac 29January63
31Ac 125Ac 1February25
32Ac 238Ac 2February38
33Ac 36Ac 3February6
34Ac 467Ac 4February67
35Ac 599Ac 5February99
Sheet1
Cell Formulas
RangeFormula
O2:P349O2=HSTACK(TOCOL(IF(SEQUENCE(,12),A2:A30),,1),TOCOL(B2:M30,,1))
R2:T349R2=TEXTSPLIT(TEXTJOIN(":",,TOCOL(IF(SEQUENCE(,12),A2:A30&"|"&B1:M1&"|"&B2:M30),,1)),"|",":")
Dynamic array formulas.
Some how, the second formula (textjoin) does not work - I get a CALC error. Saying text is to long?

I am on a EU version - dont know of any of the signs | or : is different ? i know US used , where EU use ;

is i posible to download a workbook example? :)

kasper
 
Upvote 0
the second formula (textjoin) does not work - I get a CALC error. Saying text is to long?
TEXTJOIN has a limit of 32,767 characters. I assume then that your actual range is much bigger than the A1:M30 you described in post 1, or else the data in each cell is quite long.

is i posible to download a workbook example?
You cannot attach an actual file in the forum but you can give sample data using XL2BB as I did above.
(If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

However, if @hagia_sofia's suggestion does what you want, you probably don't need to provide anything here. :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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