How to organize rows with same info in columns?

joaopauloloyola

New Member
Joined
Dec 4, 2018
Messages
1
Hello,

I need to take multiple rows with same information as below:

05LKUFD.png


And organize in columns like this:

AFaystC.png


I have a thousand of these to do and copying and pasting with transpose is not an option :(
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
My script will copy your data from the active sheet and paste it the way you want onto sheet(2)
Now this does do a copy and transpose which you said would take forever and was not a Option.
But even if you had thousands I would not think it would take no longer the a minute or two.

I know of no other way to do this:

Just have a empty sheet(2) where this will be copied to:
Code:
Sub Copy_Paste()
'Modified  12/4/2018  1:12:17 PM  EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Dim Lastrowa As Long
Lastrowa = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1
    For i = 1 To Lastrow Step 5
        Sheets(1).Cells(i, 2).Resize(5).Copy
        Sheets(2).Cells(Lastrowa, 1).PasteSpecial xlPasteValues, Transpose:=True
        Lastrowa = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1
    Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Hi & welcome to MrExcel.
Another option
Code:
Sub CopyTranspose()
   Dim Rng As Range
   Dim Ws As Worksheet
   
   Set Ws = Sheets("sheet1")
   With Sheets("sheet2")
      .Range("A2:D2").Value = Application.Transpose(Ws.Range("A1:A4").Value)
      For Each Rng In Ws.Range("B1", Ws.Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
         .Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 4).Value = Application.Transpose(Rng.Value)
      Next Rng
   End With
   
End Sub
 
Upvote 0
If my code worked why would you suggest another option.

Hi & welcome to MrExcel.
Another option
Code:
Sub CopyTranspose()
   Dim Rng As Range
   Dim Ws As Worksheet
   
   Set Ws = Sheets("sheet1")
   With Sheets("sheet2")
      .Range("A2:D2").Value = Application.Transpose(Ws.Range("A1:A4").Value)
      For Each Rng In Ws.Range("B1", Ws.Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
         .Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 4).Value = Application.Transpose(Rng.Value)
      Next Rng
   End With
   
End Sub
 
Upvote 0
If you do have hyperlinks in those cells you would need this script:
Code:
Sub Copy_Paste()
''Modified  12/4/2018  1:52:28 PM  EST
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Dim Lastrowa As Long
Lastrowa = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1
For i = 1 To Lastrow Step 5
    Sheets(1).Cells(i, 2).Resize(5).Copy
    Sheets(2).Cells(Lastrowa, 1).PasteSpecial , Transpose:=True
    Lastrowa = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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