Transpose and Repeat header

Snaybot

New Member
Joined
Apr 28, 2015
Messages
40
Im looking for a macro that transposes my header and repeats it and puts my new table column to paste right next to it until data is sufficiently filled out

I have this
ABCD
14710
25811
36912

<tbody>
</tbody>

Regular Transposing gives me this
A123
B456
C789
D101112

<tbody>
</tbody>



i want this
A1
B4
C7
D10
A2
B5
C8
D11
A3
B6
C9
D12

<tbody>
</tbody>


My table size will vary

Thank you!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try this:-
Results start "H1"
Code:
[COLOR="Navy"]Sub[/COLOR] MG28Apr14
[COLOR="Navy"]Dim[/COLOR] Ray, nRay, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray = Range("A1").CurrentRegion
    ReDim nRay(1 To UBound(Ray, 1) * UBound(Ray, 2), 1 To 2)
[COLOR="Navy"]For[/COLOR] n = 2 To UBound(Ray, 1)
    [COLOR="Navy"]For[/COLOR] Ac = 1 To UBound(Ray, 2)
        c = c + 1
        nRay(c, 1) = Ray(1, Ac)
        nRay(c, 2) = Ray(n, Ac)
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] n
Range("H1").Resize(c, 2) = nRay
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Change the last line as below:-
Code:
sheets("Sheet2").Range("A1").Resize(c,2)= nray
 
Upvote 0
Sub MG28Apr14
Dim Ray, nRay, n As Long, c As Long, Ac As Long
Ray = Range("A1").CurrentRegion
ReDim nRay(1 To UBound(Ray, 1) * UBound(Ray, 2), 1 To 2)
For n = 2 To UBound(Ray, 1)
For Ac = 1 To UBound(Ray, 2)
c = c + 1
nRay(c, 1) = Ray(1, Ac)
nRay(c, 2) = Ray(n, Ac)
Next Ac
Next n

sheets("Sheet2").Range("A1").Resize(c,2)= nrayEnd Sub</pre>
 
Upvote 0
I've a Similar problem with an Addional condition.

I've This


Product NoTUV_ModelTUV_OverallLengthTUV_OverallWidthTUV_OverallHeightTUV_WheelbaseTUV_EngineCapacity
Product 1D14520mm1850mm1880mm2760mm2489
Product 2D24520mm1850mm1880mm2760mm2489
Product 3D34520mm1850mm1880mm2760mm2489

<tbody>
</tbody>


I Want This

Product 1TUV_ModelD1
Product 1TUV_OverallLength4520mm
Product 1TUV_OverallWidth1850mm
Product 1TUV_OverallHeight1880mm
Product 1TUV_Wheelbase2760mm
Product 1TUV_EngineCapacity2489
Product 2TUV_ModelD2
Product 2TUV_OverallLength4520mm
Product 2TUV_OverallWidth1850mm
Product 2TUV_OverallHeight1880mm
Product 2TUV_Wheelbase2760mm
Product 2TUV_EngineCapacity2489
Product 3TUV_ModelD3
Product 3TUV_OverallLength4520mm
Product 3TUV_OverallWidth1850mm
Product 3TUV_OverallHeight1880mm
Product 3TUV_Wheelbase2760mm
Product 3TUV_EngineCapacity2489

<tbody>
</tbody>


In addition to the above query I Just have Want to repeat value in column 1
 
Upvote 0
Kinngs:-
Try this for results on sheet2
Code:
[COLOR="Navy"]Sub[/COLOR] MG13Jun05
[COLOR="Navy"]Dim[/COLOR] Ray [COLOR="Navy"]As[/COLOR] Variant, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
 Ray = Cells(1).CurrentRegion
 ReDim nray(1 To UBound(Ray, 1) * UBound(Ray, 2), 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("A1").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
Thank You Mick, Superb!

Kinngs:-
Try this for results on sheet2
Code:
[COLOR=Navy]Sub[/COLOR] MG13Jun05
[COLOR=Navy]Dim[/COLOR] Ray [COLOR=Navy]As[/COLOR] Variant, c [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] n [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] Ac [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long[/COLOR]
 Ray = Cells(1).CurrentRegion
 ReDim nray(1 To UBound(Ray, 1) * UBound(Ray, 2), 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("A1").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,216,727
Messages
6,132,354
Members
449,720
Latest member
NJOO7

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