How to transpose the data vertically

akhendre88

Board Regular
Joined
Sep 17, 2015
Messages
76
Hello All,

Can we transpose the data vertically. I have some data in below format.
Emp Id
Access Id
Roles
A001
abcd
READ
WRITE
DELETE

<tbody>
</tbody>




So is there any way so that I align the data in 'Roles' column like
Emp Id
Access Id
Roles
A001
abcd
READ
WRITE
DELETE

<tbody>
</tbody>







I was trying this,
Code:
sht.Range("C" & i) = WorksheetFunction.Transpose(.Range("C" & i))sht.Range("C" & i) = WorksheetFunction.Transpose(.Range("C" & i))
but the output was only first value i.e. READ.

Please suggest.

Thank you :)
 
Excellent Point Peter. I have changed up the code as follows:
Cheers. :)
An alternative would have been just to keep referencing all relevant cells etc to that worksheet, as you had started to do.

Code:
    With s1
        
        .Range("A1:C1").Copy s2.Range("A1")
        r1 = .Range("A" & Rows.Count).End(xlUp).Row
        For i = 2 To r1
            r2 = s2.Range("C" & Rows.Count).End(xlUp).Row
            .Range("A" & i & ":B" & i).Copy s2.Range("A" & r2 + 1)
            lc = [COLOR="#FF0000"][B][SIZE=5].[/SIZE][/B][/COLOR]Cells(i, [COLOR="#FF0000"][B][SIZE=5].[/SIZE][/B][/COLOR]Columns.Count).End(xlToLeft).Column
            .Range([COLOR="#FF0000"][SIZE=5][B].[/B][/SIZE][/COLOR]Cells(i, 3), [COLOR="#FF0000"][B][SIZE=5].[/SIZE][/B][/COLOR]Cells(i, lc)).Copy
            s2.Range("C" & r2 + 1).PasteSpecial xlPasteAll, , , True
            Application.CutCopyMode = False
        Next i
    End With
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
can i make the following transpose :
THE ORIGIN :
ABCDEFGHIJK
sizes
1ITEM NODESCRIPTIONCOLORU/PRICE35363738394041
2Q8-8940-2WOMENSILVERUS$10.00123456
3WOMENGOLDUS$10.00789101112
4QS-2307-32MENWHITEUS$6.70131415161718
5MENBLACKUS$6.70192021222324
6MENGOLDUS$6.70252627282930
7270#KIDSBLACKUS$10.30313233343536
8KIDSPINKUS$10.30373839404142
9M0-1116-1039UNISEXBEIGEUS$5.80434445464748
10UNISEXPINKUS$5.80495051525354

<tbody>
</tbody>

TO BECOME LIKE THIS :
MNOPQR
1ITEM NODESCRIPTIONCOLORU/PRICEsizes
2Q8-8940-2WOMENSILVERUS$10.0035
3 361
4 372
5 383
6 394
7 405
8 416
9Q8-8940-2WOMENGOLDUS$10.0035
10 367
11 378
12 389
13 3910
14 4011
15 4112
16QS-2307-32MENWHITEUS$6.7035
17 3613
18 3714
19 3815
20 3916
21 4017
22 4118
23QS-2307-32MENBLACKUS$6.7035
24 3619
25 3720
26 3821
27 3922
28 4023
29 4124
30QS-2307-32MENGOLDUS$6.7035
31 3625
32 3726
33 3827
34 3928
35 4029
36 4130
37270#KIDSBLACKUS$10.3035
38 3631
39 3732
40 3833
41 3934
42 4035
43 4136
44270#KIDSPINKUS$10.3035
45 3637
46 3738
47 3839
48 3940
49 4041
50 4142
51M0-1116-1039UNISEXBEIGEUS$5.803543
52 3644
53 3745
54 3846
55 3947
56 4048
57 41
58M0-1116-1039UNISEXPINKUS$5.803549
59 3650
60 3751
61 3852
62 3953
63 4054
64 41

<colgroup><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Last edited:
Upvote 0
shall i open a new thread since i'm asking a new question ? or i shall only wait for the answer to my questions above ?
looking forward to your answers ,
thanks
 
Upvote 0
shall i open a new thread since i'm asking a new question ?
You would do one or the other, not both. Since you have already asked the question here, this is where it stays. Please also read my Private Message about this issue.



looking forward to your answers ,
thanks
Your requirement is not clear. You have asked to how to fill the blank cells with what is above. In that case what values do you expect to see in cells R1, R2, R9 etc?
My guess is nothing, but that is not what your question implies & it is up to you to clarify exactly what you want.
 
Upvote 0
thanks for your answer peter ,
then no need to fill in the blanks with upper cells ,
i shall need only the transpose ,
looking forward to your answer ,
thanks beforehand
 
Upvote 0
Try this on a copy of your data.

Rich (BB code):
Sub Rearrange_Data()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long, NumSizes As Long
  Dim ItmNo As String
  
  a = Range("A1:K" & Range("B" & Rows.Count).End(xlUp).Row).Value
  NumSizes = UBound(a, 2) - 4
  k = 1 - NumSizes
  ReDim b(1 To UBound(a, 1) * NumSizes, 1 To 6)
  For i = 2 To UBound(a)
    If a(i, 1) <> "" Then ItmNo = a(i, 1)
    k = k + NumSizes
    b(k, 1) = ItmNo
    For j = 2 To 4
      b(k, j) = a(i, j)
    Next j
    For j = 0 To NumSizes - 1
      b(k + j, 5) = a(1, 5 + j)
      b(k + j, 6) = a(i, 5 + j)
    Next j
  Next i
  With Range("M1:R1")
    .Value = Array("ITEM NO", "DESCRIPTION", "COLOR", "U/PRICE", "sizes", "")
    .Offset(1).Resize(UBound(b)).Value = b
    .EntireColumn.AutoFit
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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