Put values from column in one cell seperated by comma

MrPowerQuery

New Member
Joined
Aug 7, 2018
Messages
11
Hello there everyone,

i have a table that looks like this:

CUSTOMERCUSTOMSUPArt.No.PAGE
Kunde AAnsprechpartner A10000011
Kunde AAnsprechpartner A10000012
Kunde AAnsprechpartner A10000013
Kunde BAnsprechpartner B10000024
Kunde BAnsprechpartner B10000025
Kunde BAnsprechpartner B10000026
Kunde BAnsprechpartner B10000027
Kunde BAnsprechpartner B10000028
Kunde BAnsprechpartner B10000029
Kunde cAnsprechpartner c100000310
Kunde cAnsprechpartner c100000311
Kunde cAnsprechpartner c100000312
Kunde DAnsprechpartner D100000413
Kunde DAnsprechpartner D100000414
Kunde DAnsprechpartner D100000415
Kunde DAnsprechpartner D100000416

<tbody>
</tbody>

The task is to write a formula or vba makro that does the following trick:
If the value in column "Art.No" changes put the value of the column "PAGE" into a other cell seperated by a comma.

Like in this case "3, 9, 12".

I tried this with the formula =IF(C2=C3;"";D2) but i dont know how to put these results in one cell seperated by commas....

Iam very sure some of u guys know how to solve my problem.

Thanks in Advance for helping me out here.

Ben
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi. I'm not a formula expert so while waiting you can use this macro that will do the trick :

Code:
Sub test()
    
    Dim c As Range
    Dim str As String

    For Each c In Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row)
        
        If c.Offset(1, 0).Value <> c.Value And c.Offset(1, 0).Value <> "" Then str = str & ", " & c.Offset(0, 1).Value
        
    Next c
    
    str = Right(str, Len(str) - 2)
    Range("E1").Value = str

End Sub

Result will be dislayed in Cell E1.
I am also curious to discover the formula solution.
 
Upvote 0
Hi louisH,

this worked perfectly. Thanks a lot!

The Formula solution is a quite complex one and i still have not figured out what it really does:
F2: =IF(C2=C3;F3;D2& ", "&F3)
G2: =LEFT(F2;LEN(F2)-2) This deletes the last 2 figures to clean the string up, because there are not needed.

Maybe u get it.
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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