Transpose data - more complex

brendanolear

Active Member
Joined
Apr 26, 2008
Messages
366
Hi seeking guidance on the following:

I have a table of data with staff names in Column A and Performance numbers in same row thereafter.

What I am trying to do is convert the top table in my example to the bottom table but do not know how to; using either transpose data or vlookup/hlookup etc.

I can do it with lots of cutting and pasting but there must be a simple way - please.

NameP1P2P3P4
A.Smith50604235
C.Jones25121618
N.Brown45121614
A.SmithP150
A.SmithP260
A.SmithP342
A.SmithP435
C.JonesP125
C.JonesP212
C.JonesP316
C.JonesP418
N.BrownP145
N.BrownP212
N.BrownP316
N.BrownP414

<colgroup><col width="64" style="width:48pt" span="5"> </colgroup><tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
If you can use a bit of code, this will place the desired result on sheet2.
Code:
[COLOR="Navy"]Sub[/COLOR] MG19Sep04
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ray [COLOR="Navy"]As[/COLOR] Variant, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray = ActiveSheet.Cells(1).CurrentRegion
ReDim nRay(1 To UBound(Ray, 1) * UBound(Ray, 2) + 1, 1 To 3)
[COLOR="Navy"]For[/COLOR] n = 2 To UBound(Ray, 1)
    [COLOR="Navy"]For[/COLOR] Ac = 2 To UBound(Ray, 2)
        c = c + 1
        nRay(c, 1) = Ray(n, 1)
            nRay(c, 2) = Ray(1, Ac)
                nRay(c, 3) = Ray(n, Ac)
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]With[/COLOR] Sheets("Sheet2").Range("A2").Resize(c, 3)
    .Value = nRay
    .Borders.Weight = 2
    .Columns.AutoFit
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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