Horizontal to Vertical

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
696
Office Version
  1. 2019
Platform
  1. Windows
NFL.xlsm
ABCDEFGHIJKLMNOP
1WeekWeekWeekweekHOUSEATENWeekJAXWASNEWeekMIACHILAR
21231KCATLDEN2TENARZSEA3JAXATLBUF
3HOUJAX
4KCTEN
5SEAWAS
6ATLARZ
7TENNE
8DENSEA
Sheet1


I'm looking to convert the Horizontal listing to Vertical, using a new column when "week" shows.
Vertical listing starts in Col A, then inserts a column to insert 2nd week (Col B), etc. 'insert' so it doesn't over-ride the original Horizontal listing (E:P).
 

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.
Hi, can you write the vertical and horizontal listings in two separate sheets? in that case you wouldn't have to bother with inserting columns and would simply need to use OFFSET().
 
Upvote 0
Hi, can you write the vertical and horizontal listings in two separate sheets? in that case you wouldn't have to bother with inserting columns and would simply need to use OFFSET().
Yes, two separate sheet are fine. thx
 
Upvote 0
Here is a VBA way. I put the original data on a sheet called 'Raw', and the results are shown on sheet 'Output'.

Book1
ABC
1Week1Week2Week3
2HOUJAXMIA
3SEAWASCHI
4TENNELAR
5KCTENJAX
6ATLARZATL
7DENSEABUF
Output


VBA Code:
Sub PX()
Dim Raw As Worksheet:       Set Raw = Sheets("Raw")
Dim OP As Worksheet:        Set OP = Sheets("Output")
Dim AR() As Variant:        AR = Raw.Range("A1:L2").Value2
Dim SD As Object:           Set SD = CreateObject("Scripting.Dictionary")
Dim c As Integer:           c = 1
Dim wNum As String
Dim r As Range

Dim SP() As String

For ro = LBound(AR) To UBound(AR)
    For co = LBound(AR) To UBound(AR, 2)
        If co Mod 4 = 1 Then
            wNum = AR(1, co)
        Else
            If SD.exists(wNum) Then
                SD(wNum) = SD(wNum) & "-" & AR(ro, co)
            Else
                SD(wNum) = AR(ro, co)
            End If
        End If
    Next co
Next ro

Set r = OP.Range("A1")
Set r = r.Resize(1, SD.Count)
r.Value = SD.keys

For Each k In SD.keys
    SP = Split(SD(k), "-")
    OP.Range(OP.Cells(2, c), OP.Cells(2, c)).Resize(UBound(SP) + 1, 1).Value2 = Application.Transpose(SP)
    c = c + 1
Next k

End Sub
 
Upvote 0
With Excel formulas, if your horizontal listing is on Sheet2 and your vertical listing on Sheet1, for the week number you just need to write in A2 =OFFSET(Sheet2!A2,0,3*(COLUMN()-1)) and expand to the right, then in A3 =OFFSET(Sheet2!B1,0,3*(COLUMN()-1)) and so on, once the 7 formulas are written, you just need to expand everything to the right.
 
Upvote 0
Here is a VBA way. I put the original data on a sheet called 'Raw', and the results are shown on sheet 'Output'.

Book1
ABC
1Week1Week2Week3
2HOUJAXMIA
3SEAWASCHI
4TENNELAR
5KCTENJAX
6ATLARZATL
7DENSEABUF
Output


VBA Code:
Sub PX()
Dim Raw As Worksheet:       Set Raw = Sheets("Raw")
Dim OP As Worksheet:        Set OP = Sheets("Output")
Dim AR() As Variant:        AR = Raw.Range("A1:L2").Value2
Dim SD As Object:           Set SD = CreateObject("Scripting.Dictionary")
Dim c As Integer:           c = 1
Dim wNum As String
Dim r As Range

Dim SP() As String

For ro = LBound(AR) To UBound(AR)
    For co = LBound(AR) To UBound(AR, 2)
        If co Mod 4 = 1 Then
            wNum = AR(1, co)
        Else
            If SD.exists(wNum) Then
                SD(wNum) = SD(wNum) & "-" & AR(ro, co)
            Else
                SD(wNum) = AR(ro, co)
            End If
        End If
    Next co
Next ro

Set r = OP.Range("A1")
Set r = r.Resize(1, SD.Count)
r.Value = SD.keys

For Each k In SD.keys
    SP = Split(SD(k), "-")
    OP.Range(OP.Cells(2, c), OP.Cells(2, c)).Resize(UBound(SP) + 1, 1).Value2 = Application.Transpose(SP)
    c = c + 1
Next k

End Sub
I didn't get the correct output.
I created a Raw sheet and Output sheet. Raw contains the actual data used for conversion.

Results of the macro:
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABAC
1WeekNYJGBTBTENATLSFJAXNECHIOAKDALDENCLELACPHIINDHOULARDETMINNOBALPITSEANYGBUFKCWAS
2HOUOAKMIAARZWeekDETLARWASNOLARSFGBARZNOPITBUFNYGMIAARZPITNYJSFHOUNOWeekPHIWeekARZATL
3SEACHIPHIDALCINMINDENBALWeekWASCINKCINDMINBALLARMINNYJWeekNOLARDALCARNEDALNENEMINOAK
4CLEINDLACPITNYGBUFCARKCMIATENHOUWeekJAXSEANYGMIALACGBNYGCLEJAXTBDETWeekNODENDENINDARZ
5TBCARLACCHIDETWASPHIOAKBUFNYGLACSEANYJCARDALTENTBDALPHIINDSFSFMINBAL13GBCARSFTB
6CARDETCARWeekPHIBALPITDENPHIOAKNYGKCSEAARZKCWASHOUGBTENCINTBKCWeekWeekBALLACHOUPITDEN
7CINTBBUFATLNECLETBARZATLMIATENSFSFMIALARSFWASTENBUFJAXMIACHIARZLACATLKCNYJWeekLAR
8KCATLPITSF2GBPHITENCLEWASNOCLEDETTENDALDENDALTBKCSEAPITTB14NYG
9CINNOATLLARCLEINDCINOAKSEACLEBALNYGHOUWASSEALAC7JAXMIAPHIMINNYJLARTB
10DETWASCINNYGCHIMIABUFINDPHILAR4CINMIALARNOTBPHINELACNYGTEN10CAROAK
11GBCARNELARCARNYGLACOAKATLNYGARZCARMINMINCARCINDALBALARZLARJAXCLEGBDAL
12DENDETWAS8CLEPHINYJ3INDPHIDENCHINEOAKCLEDETGBCARDETTBKC15INDCIN
13SEAJAXCINCARHOUPITDALJAXCARPITNECINNYJTBDETJAXNECINOAKGBMINOAKLAR16
14HOULACMIAARZOAKBUFBUFMIAHOUCHI
15WASARZNOHOUSFCLECINLARMIA11
16BALDENNYJLACGBMININDNOMINSEA
17MIALACJAXKCCINWASPITNYJATLCLE
18NOPHINONECLELACTENBALBALDET
19GBSFWASNYJDETARZARZHOUMIAHOU
20KCNYGNYG
21ATLPITWAS
22BALARZARZ
23CHIKCKC
24ATLNEPIT
25BALNYGWAS
26BUF
27IND
28JAX
29SF
30ATL
31BUF
32DET
33DAL
34PIT
35BUF
36CAR
37CHI
Output


Here is the data for conversion:

NFL.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZEAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQFRFSFTFUFVFWFXFYFZGAGBGCGDGEGFGGGHGIGJGKGLGMGNGOGPGQGRGSGTGUGVGWGXGYGZHAHBHCHDHEHFHGHHHIHJHKHLHMHNHOHPHQHRHSHTHUHVHWHXHYHZIAIBICIDIEIFIGIHIIIJIKILIMINIOIPIQIRISITIUIVIWIXIYIZJAJBJCJDJEJFJGJHJIJJJKJLJM
1WeekHOUSEACLENYJOAKCHIINDGBMIAPHILACTBARZDALPITTENWeekCINNYGATLDETMINBUFSFLARDENCARJAXWASBALKCNENOWeekMIACHILARWASTENOAKSFCINHOUNYJCARDETTBDALGBKCWeekDENARZINDJAXCLENOMINSEALACPITBALNYGNEBUFPHIATLWeekTBCARCINJAXOAKDENARZPHIBUFLARMIAINDNYGMINLACWeekKCCINDETATLWASBALCLEHOUMIANYJGBLARARZWeekNYGDETPITNOCLEGBLACCARBUFDALSEAKCSFTBCHIWeekATLNETENOAKINDMINNYJLARJAXNOSFDALTBWeekGBDENSEABALHOUCARDETCHINYGOAKMIAPITNONEWeekINDTBHOUWASJAXPHICINBUFDENNYJSEASFBALMINWeekARZTENDETPHINEGBPITATLCINLACDALKCLARWeekHOUWASBALOAKLACNYGTENCLECARARZMIANOSFKCCHISEAWeekDALNODETINDCINJAXOAKWASCLELARNYGPHINEDENBUFWeekNEDENHOUDALGBTENKCARZMININDNYJATLNOWASPITBALWeekLACBUFCARHOUNYJDETTBJAXNECHICLESEAPHIKCSFPITWeekMINSFTBMIADENCLENYGCINCHIATLINDCARLARPHITENBUFWeekMIANOGBBALPITMINTENJAXLACNYJDALWASATLOAKARZSEA
21KCATLBALBUFCARDETJAXMINNEWASCINNOSFLARNYGDEN2CLECHIDALGBINDMIANYJPHIPITTBTENARZHOULACSEAOAK3JAXATLBUFCLEMINNENYGPHIPITINDLACARZDENSEANOBAL4NYJCARCHICINDALDETHOUMIATBTENWASLARKCOAKSFGB5CHIATLBALHOUKCNENYJPITTENWASSFCLEDALSEANO6BUFINDJAXMINNYGPHIPITTENDENLACTBSFDAL7PHIATLBALCARCINHOUMIANONYJWASARZDENNEOAKLAR8CARBUFCINCLEDETGBKCMIALACCHISEAPHINYG9SFATLBUFINDJAXKCMINTENWASLACARZDALTBNYJ10TENCARCLEDETGBNYGPITARZOAKMIALARNONECHI11SEABALCARCLEHOUINDJAXNOWASDENMINOAKTB12DETDALPITATLBUFCININDJAXMINNENYJDENLARTBGBPHI13BALATLCHIHOUMIAMINNYJPITTENARZSEAGBLACKCSF14LARCARCHICINDETJAXMIANYGTBOAKSEALACPHISFBUFCLE15OAKDENGBINDLARTENATLBALMIAMINNYGWASARZNODALCIN16NOARZDETOAKLACNYJBALHOUJAXKCPITWASSEADALGBNE17BUFCARCHICINCLEDETHOUINDKCNENYGPHITBDENLARSF
Raw


Thank you.
 
Upvote 0
I didn't get the correct output.
I created a Raw sheet and Output sheet. Raw contains the actual data used for conversion.

Results of the macro:
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABAC
1WeekNYJGBTBTENATLSFJAXNECHIOAKDALDENCLELACPHIINDHOULARDETMINNOBALPITSEANYGBUFKCWAS
2HOUOAKMIAARZWeekDETLARWASNOLARSFGBARZNOPITBUFNYGMIAARZPITNYJSFHOUNOWeekPHIWeekARZATL
3SEACHIPHIDALCINMINDENBALWeekWASCINKCINDMINBALLARMINNYJWeekNOLARDALCARNEDALNENEMINOAK
4CLEINDLACPITNYGBUFCARKCMIATENHOUWeekJAXSEANYGMIALACGBNYGCLEJAXTBDETWeekNODENDENINDARZ
5TBCARLACCHIDETWASPHIOAKBUFNYGLACSEANYJCARDALTENTBDALPHIINDSFSFMINBAL13GBCARSFTB
6CARDETCARWeekPHIBALPITDENPHIOAKNYGKCSEAARZKCWASHOUGBTENCINTBKCWeekWeekBALLACHOUPITDEN
7CINTBBUFATLNECLETBARZATLMIATENSFSFMIALARSFWASTENBUFJAXMIACHIARZLACATLKCNYJWeekLAR
8KCATLPITSF2GBPHITENCLEWASNOCLEDETTENDALDENDALTBKCSEAPITTB14NYG
9CINNOATLLARCLEINDCINOAKSEACLEBALNYGHOUWASSEALAC7JAXMIAPHIMINNYJLARTB
10DETWASCINNYGCHIMIABUFINDPHILAR4CINMIALARNOTBPHINELACNYGTEN10CAROAK
11GBCARNELARCARNYGLACOAKATLNYGARZCARMINMINCARCINDALBALARZLARJAXCLEGBDAL
12DENDETWAS8CLEPHINYJ3INDPHIDENCHINEOAKCLEDETGBCARDETTBKC15INDCIN
13SEAJAXCINCARHOUPITDALJAXCARPITNECINNYJTBDETJAXNECINOAKGBMINOAKLAR16
14HOULACMIAARZOAKBUFBUFMIAHOUCHI
15WASARZNOHOUSFCLECINLARMIA11
16BALDENNYJLACGBMININDNOMINSEA
17MIALACJAXKCCINWASPITNYJATLCLE
18NOPHINONECLELACTENBALBALDET
19GBSFWASNYJDETARZARZHOUMIAHOU
20KCNYGNYG
21ATLPITWAS
22BALARZARZ
23CHIKCKC
24ATLNEPIT
25BALNYGWAS
26BUF
27IND
28JAX
29SF
30ATL
31BUF
32DET
33DAL
34PIT
35BUF
36CAR
37CHI
Output


Here is the data for conversion:

NFL.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCPCQCRCSCTCUCVCWCXCYCZDADBDCDDDEDFDGDHDIDJDKDLDMDNDODPDQDRDSDTDUDVDWDXDYDZEAEBECEDEEEFEGEHEIEJEKELEMENEOEPEQERESETEUEVEWEXEYEZFAFBFCFDFEFFFGFHFIFJFKFLFMFNFOFPFQFRFSFTFUFVFWFXFYFZGAGBGCGDGEGFGGGHGIGJGKGLGMGNGOGPGQGRGSGTGUGVGWGXGYGZHAHBHCHDHEHFHGHHHIHJHKHLHMHNHOHPHQHRHSHTHUHVHWHXHYHZIAIBICIDIEIFIGIHIIIJIKILIMINIOIPIQIRISITIUIVIWIXIYIZJAJBJCJDJEJFJGJHJIJJJKJLJM
1WeekHOUSEACLENYJOAKCHIINDGBMIAPHILACTBARZDALPITTENWeekCINNYGATLDETMINBUFSFLARDENCARJAXWASBALKCNENOWeekMIACHILARWASTENOAKSFCINHOUNYJCARDETTBDALGBKCWeekDENARZINDJAXCLENOMINSEALACPITBALNYGNEBUFPHIATLWeekTBCARCINJAXOAKDENARZPHIBUFLARMIAINDNYGMINLACWeekKCCINDETATLWASBALCLEHOUMIANYJGBLARARZWeekNYGDETPITNOCLEGBLACCARBUFDALSEAKCSFTBCHIWeekATLNETENOAKINDMINNYJLARJAXNOSFDALTBWeekGBDENSEABALHOUCARDETCHINYGOAKMIAPITNONEWeekINDTBHOUWASJAXPHICINBUFDENNYJSEASFBALMINWeekARZTENDETPHINEGBPITATLCINLACDALKCLARWeekHOUWASBALOAKLACNYGTENCLECARARZMIANOSFKCCHISEAWeekDALNODETINDCINJAXOAKWASCLELARNYGPHINEDENBUFWeekNEDENHOUDALGBTENKCARZMININDNYJATLNOWASPITBALWeekLACBUFCARHOUNYJDETTBJAXNECHICLESEAPHIKCSFPITWeekMINSFTBMIADENCLENYGCINCHIATLINDCARLARPHITENBUFWeekMIANOGBBALPITMINTENJAXLACNYJDALWASATLOAKARZSEA
21KCATLBALBUFCARDETJAXMINNEWASCINNOSFLARNYGDEN2CLECHIDALGBINDMIANYJPHIPITTBTENARZHOULACSEAOAK3JAXATLBUFCLEMINNENYGPHIPITINDLACARZDENSEANOBAL4NYJCARCHICINDALDETHOUMIATBTENWASLARKCOAKSFGB5CHIATLBALHOUKCNENYJPITTENWASSFCLEDALSEANO6BUFINDJAXMINNYGPHIPITTENDENLACTBSFDAL7PHIATLBALCARCINHOUMIANONYJWASARZDENNEOAKLAR8CARBUFCINCLEDETGBKCMIALACCHISEAPHINYG9SFATLBUFINDJAXKCMINTENWASLACARZDALTBNYJ10TENCARCLEDETGBNYGPITARZOAKMIALARNONECHI11SEABALCARCLEHOUINDJAXNOWASDENMINOAKTB12DETDALPITATLBUFCININDJAXMINNENYJDENLARTBGBPHI13BALATLCHIHOUMIAMINNYJPITTENARZSEAGBLACKCSF14LARCARCHICINDETJAXMIANYGTBOAKSEALACPHISFBUFCLE15OAKDENGBINDLARTENATLBALMIAMINNYGWASARZNODALCIN16NOARZDETOAKLACNYJBALHOUJAXKCPITWASSEADALGBNE17BUFCARCHICINCLEDETHOUINDKCNENYGPHITBDENLARSF
Raw


Thank you.
Conversion must be B1&B2, C1&C2, D1&D2, etc. Then new column for Week 2 S1&S2, T1&T2, U1&U2, etc, then week 3, 4 ,5 etc.
Week 1
B1
B2
C1
C2
D1
D2
etc
new column for:
Week 2
S1
S2
T1
T2
etc
 
Upvote 0
Try this.

Book1 (version 1).xlsb
ABCDEFGHIJKLMNOPQ
1Week1Week2Week3Week4Week5Week6Week7Week8Week9Week10Week11Week12Week13Week14Week15Week16Week17
2HOUCINMIADENTBKCNYGATLGBINDARZHOUDALNELACMINMIA
3SEANYGCHIARZCARCINDETNEDENTBTENWASNODENBUFSFNO
4CLEATLLARINDCINDETPITTENSEAHOUDETBALDETHOUCARTBGB
5NYJDETWASJAXJAXATLNOOAKBALWASPHIOAKINDDALHOUMIABAL
6OAKMINTENCLEOAKWASCLEINDHOUJAXNELACCINGBNYJDENPIT
7CHIBUFOAKNODENBALGBMINCARPHIGBNYGJAXTENDETCLEMIN
8INDSFSFMINARZCLELACNYJDETCINPITTENOAKKCTBNYGTEN
9GBLARCINSEAPHIHOUCARLARCHIBUFATLCLEWASARZJAXCINJAX
10MIADENHOULACBUFMIABUFJAXNYGDENCINCARCLEMINNECHILAC
11PHICARNYJPITLARNYJDALNOOAKNYJLACARZLARINDCHIATLNYJ
12LACJAXCARBALMIAGBSEASFMIASEADALMIANYGNYJCLEINDDAL
13TBWASDETNYGINDLARKCDALPITSFKCNOPHIATLSEACARWAS
14ARZBALTBNENYGARZSFTBNOBALLARSFNENOPHILARATL
15DALKCDALBUFMINBUFTBCARNEMINSEAKCDENWASKCPHIOAK
16PITNEGBPHILACINDCHIBUFSFTENBALCHIBUFPITSFTENARZ
17TENNOKCATLCHIJAXPHICINATLCARCARSEABALBALPITBUFSEA
18KCCLEJAXNYJATLMINATLCLEBUFCLECLEDETATLLAROAKNOBUF
19ATLCHIATLCARBALNYGBALDETINDDETHOUDALCHICARDENARZCAR
20BALDALBUFCHIHOUPHICARGBJAXGBINDPITHOUCHIGBDETCHI
21BUFGBCLECINKCPITCINKCKCNYGJAXATLMIACININDOAKCIN
22CARINDMINDALNETENHOUMIAMINPITNOBUFMINDETLARLACCLE
23DETMIANEDETNYJDENMIALACTENARZWASCINNYJJAXTENNYJDET
24JAXNYJNYGHOUPITLACNOCHIWASOAKDENINDPITMIAATLBALHOU
25MINPHIPHIMIATENTBNYJSEALACMIAMINJAXTENNYGBALHOUIND
26NEPITPITTBWASSFWASPHIARZLAROAKMINARZTBMIAJAXKC
27WASTBINDTENSFDALARZNYGDALNOTBNESEAOAKMINKCNE
28CINTENLACWASCLEDENTBNENYJGBSEANYGPITNYG
29NOARZARZLARDALNENYJCHIDENLACLACWASWASPHI
30SFHOUDENKCSEAOAKLARKCPHIARZSEATB
31LARLACSEAOAKNOLARTBSFSFNODALDEN
32NYGSEANOSFGBBUFDALGBLAR
33DENOAKBALGBPHICLECINNESF
Output


VBA Code:
Sub PX()
Dim Raw As Worksheet:       Set Raw = Sheets("Raw")
Dim OP As Worksheet:        Set OP = Sheets("Output")
Dim AR() As Variant:        AR = Raw.Range("A1:JM2").Value2
Dim SD As Object:           Set SD = CreateObject("Scripting.Dictionary")
Dim c As Integer:           c = 1
Dim wNum As String
Dim r As Range

Dim SP() As String

For ro = LBound(AR) To UBound(AR)
    For co = LBound(AR) To UBound(AR, 2)
        If InStr(AR(1, co), "Week") > 0 Then
            wNum = AR(1, co) & AR(2, co)
        Else
            If SD.exists(wNum) Then
                SD(wNum) = SD(wNum) & "-" & AR(ro, co)
            Else
                SD(wNum) = AR(ro, co)
            End If
        End If
    Next co
Next ro

Set r = OP.Range("A1")
Set r = r.Resize(1, SD.Count)
r.Value = SD.keys

For Each k In SD.keys
    SP = Split(SD(k), "-")
    OP.Range(OP.Cells(2, c), OP.Cells(2, c)).Resize(UBound(SP) + 1, 1).Value2 = Application.Transpose(SP)
    c = c + 1
Next k

End Sub
 
Upvote 0
Another option
VBA Code:
Sub gtd()
   Dim Ary As Variant, Nary As Variant
   Dim c As Long, nr As Long, nc As Long
   
   Ary = Sheets("Raw").Range("A1").CurrentRegion.Value2
   ReDim Nary(1 To 34, 1 To UBound(Ary, 2))
   
   For c = 1 To UBound(Ary, 2)
      If LCase(Ary(1, c)) = "week" Then
         nr = 1: nc = nc + 1
      Else
         nr = nr + 2
      End If
      Nary(nr, nc) = Ary(1, c)
      Nary(nr + 1, nc) = Ary(2, c)
   Next c
   Sheets("Sheet1").Range("A1").Resize(UBound(Nary), nc).Value = Nary
End Sub
 
Upvote 0
Solution
Try this.

Book1 (version 1).xlsb
ABCDEFGHIJKLMNOPQ
1Week1Week2Week3Week4Week5Week6Week7Week8Week9Week10Week11Week12Week13Week14Week15Week16Week17
2HOUCINMIADENTBKCNYGATLGBINDARZHOUDALNELACMINMIA
3SEANYGCHIARZCARCINDETNEDENTBTENWASNODENBUFSFNO
4CLEATLLARINDCINDETPITTENSEAHOUDETBALDETHOUCARTBGB
5NYJDETWASJAXJAXATLNOOAKBALWASPHIOAKINDDALHOUMIABAL
6OAKMINTENCLEOAKWASCLEINDHOUJAXNELACCINGBNYJDENPIT
7CHIBUFOAKNODENBALGBMINCARPHIGBNYGJAXTENDETCLEMIN
8INDSFSFMINARZCLELACNYJDETCINPITTENOAKKCTBNYGTEN
9GBLARCINSEAPHIHOUCARLARCHIBUFATLCLEWASARZJAXCINJAX
10MIADENHOULACBUFMIABUFJAXNYGDENCINCARCLEMINNECHILAC
11PHICARNYJPITLARNYJDALNOOAKNYJLACARZLARINDCHIATLNYJ
12LACJAXCARBALMIAGBSEASFMIASEADALMIANYGNYJCLEINDDAL
13TBWASDETNYGINDLARKCDALPITSFKCNOPHIATLSEACARWAS
14ARZBALTBNENYGARZSFTBNOBALLARSFNENOPHILARATL
15DALKCDALBUFMINBUFTBCARNEMINSEAKCDENWASKCPHIOAK
16PITNEGBPHILACINDCHIBUFSFTENBALCHIBUFPITSFTENARZ
17TENNOKCATLCHIJAXPHICINATLCARCARSEABALBALPITBUFSEA
18KCCLEJAXNYJATLMINATLCLEBUFCLECLEDETATLLAROAKNOBUF
19ATLCHIATLCARBALNYGBALDETINDDETHOUDALCHICARDENARZCAR
20BALDALBUFCHIHOUPHICARGBJAXGBINDPITHOUCHIGBDETCHI
21BUFGBCLECINKCPITCINKCKCNYGJAXATLMIACININDOAKCIN
22CARINDMINDALNETENHOUMIAMINPITNOBUFMINDETLARLACCLE
23DETMIANEDETNYJDENMIALACTENARZWASCINNYJJAXTENNYJDET
24JAXNYJNYGHOUPITLACNOCHIWASOAKDENINDPITMIAATLBALHOU
25MINPHIPHIMIATENTBNYJSEALACMIAMINJAXTENNYGBALHOUIND
26NEPITPITTBWASSFWASPHIARZLAROAKMINARZTBMIAJAXKC
27WASTBINDTENSFDALARZNYGDALNOTBNESEAOAKMINKCNE
28CINTENLACWASCLEDENTBNENYJGBSEANYGPITNYG
29NOARZARZLARDALNENYJCHIDENLACLACWASWASPHI
30SFHOUDENKCSEAOAKLARKCPHIARZSEATB
31LARLACSEAOAKNOLARTBSFSFNODALDEN
32NYGSEANOSFGBBUFDALGBLAR
33DENOAKBALGBPHICLECINNESF
Output


VBA Code:
Sub PX()
Dim Raw As Worksheet:       Set Raw = Sheets("Raw")
Dim OP As Worksheet:        Set OP = Sheets("Output")
Dim AR() As Variant:        AR = Raw.Range("A1:JM2").Value2
Dim SD As Object:           Set SD = CreateObject("Scripting.Dictionary")
Dim c As Integer:           c = 1
Dim wNum As String
Dim r As Range

Dim SP() As String

For ro = LBound(AR) To UBound(AR)
    For co = LBound(AR) To UBound(AR, 2)
        If InStr(AR(1, co), "Week") > 0 Then
            wNum = AR(1, co) & AR(2, co)
        Else
            If SD.exists(wNum) Then
                SD(wNum) = SD(wNum) & "-" & AR(ro, co)
            Else
                SD(wNum) = AR(ro, co)
            End If
        End If
    Next co
Next ro

Set r = OP.Range("A1")
Set r = r.Resize(1, SD.Count)
r.Value = SD.keys

For Each k In SD.keys
    SP = Split(SD(k), "-")
    OP.Range(OP.Cells(2, c), OP.Cells(2, c)).Resize(UBound(SP) + 1, 1).Value2 = Application.Transpose(SP)
    c = c + 1
Next k

End Sub
Everything is working, except the order of the teams. Results are: B1, C1, D1, E1 not B1,B2,C1,C2,D1,D2
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
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