Help converting row data to column format

Fishin33

New Member
Joined
Sep 13, 2004
Messages
5
If I have a list that has a row for every product an employee has, how can I convert that to one per emloyee and there are multiple columns that contain their products.

Example

1234 Prod1
1234 Prod2
1234 Prod3
1235 Prod1
1235 Prod2
1235 Prod3
1236 Prod1
1236 Prod2

Convert to:

1234 Prod1 Prod2 Prod3
1235 Prod1 Prod2 Prod3
1236 Prod1 Prod2

Paste Special works, but only if I manually select one group of rows for the same emloyee. Is there a formula or macro I can do for this?

Thanks!!!!

Russ
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Code:
Sub CopyToCols()

    Dim rgCell As Range
    Dim i As Integer
    i = 1
    Set rgCell = [a1]
    If rgCell = "" Then Exit Sub
    If rgCell.Offset(1, 0) = "" Then Exit Sub
    Do
        If rgCell = rgCell.Offset(i, 0) Then
            rgCell.Offset(i, 1).Copy rgCell.End(xlToRight).Offset(0, 1)
            rgCell.Offset(i, 1).EntireRow.Delete
            If rgCell.Offset(1, 0) = "" Then
                Exit Sub
            End If
        Else
            Set rgCell = rgCell.Offset(1, 0)
        End If
    Loop
            
    
End Sub
Change [a1] to the starting cell ref
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,242
Members
451,756
Latest member
tommyw

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