Converting multiple rows into a single rows

dogger

New Member
Joined
May 27, 2003
Messages
18
I have a list of clients with account numbers. If the client has more than one account they are listed in another row.

For example
David 123456
David 654321
David 789456

I want to consolidate the accounts into a single row so that it would have name, account 1, account 2 etc... where the account numbers are in seperate columns.
David 123456, 654321,789456

I hope this makes sense.

Thanks
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi,

Have a look...
Book2
ABCDE
1David123456David123456, 654321, 789456
2David654321
3David789456
4
Sheet1


Formula in E1,

=aconcat(IF(A1:A3=D1,B1:B3),", ")

Confirmed with Ctrl+Shift+Enter

ACONCAT is a UDF.

Code:
Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
    Dim y As Variant
    
    If TypeOf a Is Range Then
        For Each y In a.Cells
            aconcat = aconcat & y.Value & sep
        Next y
    ElseIf IsArray(a) Then
        For Each y In a
            aconcat = aconcat & y & sep
        Next y
    Else
        aconcat = aconcat & a & sep
    End If
    aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function


HTH
 
Upvote 0
Thanks for the reply.

Looking back on my original post, I was not very clear on my situation.

I have about 3000 lines (account numbers), roughly 600 different client names and some may only have one account while others have up to 12. I have additional data that is repeated on every line for that specific client - address, city, state, Social Security number - that I would like have shown just once along with the name and account numbers.

What I am hoping to do is create a mail merge that will allow me to address the letter, list the account numbers and put their social security number under a signature line.

I appreciate you help.
 
Upvote 0
I split the task up with the folks in the office and we completed it manually. Thanks for your time.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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