capturing repeat instances

HWL

Active Member
Joined
Dec 1, 2009
Messages
462
Okay, say I have 2 columns of data. In column A I have a string on each row. Some strings may be duplicates. In column B I have a string on each row. No duplicates.

Here is what I want to do. In column D, I want to list on the same row as the first instance of a string in A, all of the associated strings from column B. Otherwise for all other instances from A, I want D to be blank. Need to be a formula I can drag down in col D.

EXAMPLE:
COL A______COL B________COL D
Bob________Wed_________Wed,Tue,Sat
Sam________Fri__________Fri,Sun
Tom________Mon_________Mon
Bob________Tue__________
Bob________Sat__________
Sam_______Sun__________

Thanks for the help
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
That's not going to be easy with built-in Excel functions, because Excel is week at concatenation. Would you be prepared to use a VBA solution?
 
Upvote 0
That's not going to be easy with built-in Excel functions, because Excel is week at concatenation. Would you be prepared to use a VBA solution?

My enduser can't use macros. I have something like:

=IF(A5="","",IF(AND(TRIM(A5)<>"",A6=""),B5&","&B6&IF(AND(A6="",A7=""),","&B7,"")&IF(AND(A7="",A8=""),","&B8,"")&IF(AND(A8="",A9=""),","&B9,""),B5))

There is a bit a variation on what I orginally posted, as col A is a value-pasted pivot table so instead of duplicate entries, there is a blank in A when there are more than one associated entries in col B.

Obviously this solution will only work upto the 7 nested IF statements.
 
Upvote 0
This is working with an xlsx file and upto 15 lvls --
=IF(A5="","",IF(AND(TRIM(A5)<>"",A6=""),B5&","&B6&IF(AND(A6="",A7=""),","&B7,"")&IF(AND(A6="", A7="",A8=""),","&B8,"")&IF(AND(A6="",A7="",A8="",A9=""),","&B9,"")&IF(AND(A6="",A7="",A8="",A9="",A10=""),","&B10,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11=""),","&B11,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12=""),","&B12,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13=""),","&B13,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14=""),","&B14,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15=""),","&B15,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16=""),","&B16,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17=""),","&B17,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18=""),","&B18,"")&IF(AND(A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19=""),","&B19,""),B5))
 
Upvote 0
Ugly isn't it? As I said Excel is poor at concatenation, so you are unlikely to find a more elegant solution.
 
Upvote 0
Ugly isn't it? As I said Excel is poor at concatenation, so you are unlikely to find a more elegant solution.

Yeah, I wish someone like the LibreOffice team would not merely try to make a copy of Excel, but work to make these kind of improvements.

Thanks.

P.S. From what I understand, I can go out 64 lvls with this formula in xlsx -- so as ugly as it is, it should cover what I'm trying to do.
 
Upvote 0

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,921
Latest member
BBQKING

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