Complicated table transpose with two columns to multiple columns

alexllap

New Member
Joined
Jan 29, 2014
Messages
11
I'm needing some help turning a table with two columns, into a table with multiple columns based on the information in the column. The table I currently have has over 300 rows and I want to turn this:

123888
OTHER US4
KSU3.92
378288
CHAMPAGNE-URBANA3.8
999914
PORTLAND STATE3.4
DARTMOUTH3.6
NORTHWESTERN3.8

<tbody>
</tbody>

into this:

123888OTHER US4KSU3.92
378288CHAMPAGNE-URBANA3.8
999914PORTLAND STATE3.4DARTMOUTH3.6NORTHWESTERN3.8

<tbody>
</tbody>

Is this possible through a formula or a macro? I'm not too savvy with VBA, but am willing to give that a go if it would be easier. The thing that makes this difficult (at least for me) is that some IDs have multiple schools/GPAs.

Any help is greatly appreciated.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try this for results starting "D1"
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Dec55
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
ReDim ray(1 To Rng.Count, 1 To 1)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Dn.Offset(, 1).Value = "" And IsNumeric(Dn.Value) [COLOR="Navy"]Then[/COLOR]
        c = c + 1: Ac = 0
    [COLOR="Navy"]End[/COLOR] If
    Ac = Ac + 1
    [COLOR="Navy"]If[/COLOR] UBound(ray, 2) < Ac [COLOR="Navy"]Then[/COLOR] ReDim Preserve ray(1 To Rng.Count, 1 To Ac)
        ray(c, Ac) = Dn.Value
    [COLOR="Navy"]If[/COLOR] Ac > 1 [COLOR="Navy"]Then[/COLOR]
        Ac = Ac + 1
        [COLOR="Navy"]If[/COLOR] UBound(ray, 2) < Ac [COLOR="Navy"]Then[/COLOR] ReDim Preserve ray(1 To Rng.Count, 1 To Ac)
    ray(c, Ac) = Dn.Offset(, 1).Value
    [COLOR="Navy"]End[/COLOR] If
    
    [COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]With[/COLOR] Range("D1").Resize(c, UBound(ray, 2))
    .Value = ray
    .Columns.AutoFit
    .Borders.Weight = 2
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi Mick,

I'm getting: "Run-time error '9': Subscript out of range" it looks like at line 13 or 14.

I copied your code into a new blank module in VBA, and tried to run it. Then, I stepped-into it and nothing happens in the table, just the error. Let me know if I'm doing something wrong.
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,665
Members
449,091
Latest member
peppernaut

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