Data from Columns to Rows (Transpose Not Working)

Hohums

New Member
Joined
Sep 16, 2014
Messages
1
Hello all,

My data is as follows:

[TABLE="width: 500"]
<tbody>[TR]
[TD]CUSTOMER[/TD]
[TD]ADDRESS[/TD]
[TD]TASK[/TD]
[/TR]
[TR]
[TD]CUST1[/TD]
[TD]ADDR1[/TD]
[TD]TASK1[/TD]
[/TR]
[TR]
[TD]CUST1[/TD]
[TD]ADDR1[/TD]
[TD]TASK2[/TD]
[/TR]
[TR]
[TD]CUST1[/TD]
[TD]ADDR1[/TD]
[TD]TASK3[/TD]
[/TR]
[TR]
[TD]CUST2[/TD]
[TD]ADDR2[/TD]
[TD]TASK1[/TD]
[/TR]
[TR]
[TD]CUST2[/TD]
[TD]ADDR2[/TD]
[TD]TASK2[/TD]
[/TR]
</tbody>[/TABLE]

And so on.

I want to move the Tasks all onto a single row. Have tried manual copy/paste with Transpose but there are too many records for this to be viable

Desired output is:

[TABLE="width: 500"]
<tbody>[TR]
[TD]CUST1[/TD]
[TD]ADDR1[/TD]
[TD]TASK1[/TD]
[TD]TASK2[/TD]
[TD]TASK3[/TD]
[/TR]
[TR]
[TD]CUST2[/TD]
[TD]ADDR2[/TD]
[TD]TASK1[/TD]
[TD]TASK2[/TD]
[TD]TASK3[/TD]
[/TR]
</tbody>[/TABLE]

Any help would be greatly appreciated!

Regards,
Hohums
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try this

Code:
Sub k1()
Dim LastRow As Long, i, j, k, LastCol As Integer
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
k = 0
l = 1
For i = 1 To LastRow
        k = k + 1
        Debug.Print i; k; l
        If k <> 1 Then
        Sheets("Sheet2").Range("A1").Offset(l - 1, k) = Sheets("Sheet1").Range("A1").Offset(i - 1, 2)
        Else
        Sheets("Sheet2").Range("A1").Offset(l - 1, 0) = Sheets("Sheet1").Range("A1").Offset(i - 1, 0)
        Sheets("Sheet2").Range("A1").Offset(l - 1, k) = Sheets("Sheet1").Range("A1").Offset(i - 1, 2)
        End If
        If k = 3 Then k = 0: l = l + 1
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,403
Messages
6,165,852
Members
451,986
Latest member
ExcelIsLove

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