Transpose data in columns from sheet 1 to rows as in sheet 2.

bwaaack

Board Regular
Joined
Dec 5, 2015
Messages
62
Office Version
  1. 365
Platform
  1. Windows
Hi! I need help to create a formula that will transpose data in columns from sheet 1 to rows as in sheet 2. Thank you in advance.

Sheet1
Item#ImageURL
10011-BKBK10011-BKBK_01.jpgassets/images/MEM_MAIN/10011-BKBK_01.jpg
10011-BKBK10011-BKBK_02_TABLETOP.jpgassets/images/MEM_ALT/10011-BKBK_02_TABLETOP.jpg
10011-GRGR10011-GRGR_01.jpgassets/images/MEM_MAIN/10011-GRGR_01.jpg
10011-GRGR10011-GRGR_02_FACE.jpgassets/images/MEM_ALT/10011-GRGR_02_FACE.jpg
10011-GRGR10011-GRGR_03_GIRL.jpgassets/images/MEM_ALT/10011-GRGR_03_GIRL.jpg
10011-RDBL10011-RDBL_01.jpgassets/images/MEM_MAIN/10011-RDBL_01.jpg

<tbody>
</tbody>



Sheet 2

Item#imageimageimageimageimage
10011-BKBKassets/images/MEM_MAIN/10011-BKBK_01.jpgassets/images/MEM_ALT/10011-BKBK_02_TABLETOP.jpg
10011-GRGRassets/images/MEM_MAIN/10011-GRGR_01.jpgassets/images/MEM_ALT/10011-GRGR_02_FACE.jpgassets/images/MEM_ALT/10011-GRGR_03_GIRL.jpg
10011-RDBLassets/images/MEM_MAIN/10011-RDBL_01.jpg

<tbody>
</tbody>
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try this


Code:
Sub Transpose_data()
    Dim datos As Range, i As Long, n As Long
    Set datos = Sheets("Sheet1").Range("A1").CurrentRegion
    For i = 2 To datos.Rows.Count
        n = WorksheetFunction.CountIf(datos.Columns(1), datos(i, 1))
        lr = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp)(2).Row
        Sheets("Sheet2").Range("A" & lr).Value = datos(i, 1)
        Sheets("Sheet2").Range("B" & lr).Resize(, n).Value = WorksheetFunction.Transpose(datos(i, 1).Resize(n, 1).Offset(, 2).Value)
        i = i + n - 1
    Next
End Sub
 
Upvote 0
Dante, thank you very much. The formula worked better than expected. Great work!
 
Upvote 0

Forum statistics

Threads
1,217,293
Messages
6,135,677
Members
449,956
Latest member
nibor

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