Display multiple unique values from column in one cell?

ivanribic

New Member
Joined
Jun 22, 2011
Messages
8
I've been fiddling with this for hours and can't make sense of it so figured I'd ask for suggestions.

I'm trying to work out a formula in column C that will display select values from column A as pictured below. I'd like it to do this only if there is more than one occurrence of a value in column B, and want it to omit the value in A that is in the current row. Hopefully that makes sense. I have been trying with an INDEX MATCH combination but cannot figure out how to display more than the first value from Column A.

=IF(COUNTIF($B$2:$B2,$B2)>1,INDEX($A$2:$A$400,MATCH($B2,$B$2:B$400,0),0),"")

I'm not sure if this can be done with a formula or if VBA makes more sense? Thanks in advance for any direction you can provide.


Compiled-Data.png


 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I think a UDF is best...

Code:
Function Compiled(rng As Range)

Application.Volatile


Dim c As Range


For Each c In rng
    If c.Row <> Application.Caller.Row Then
        If c = Application.Caller.Offset(, -1) Then Compiled = Compiled & c.Offset(, -1) & ", "
    End If
Next c


If Right(Compiled, 2) = ", " Then Compiled = Left(Compiled, Len(Compiled) - 2)
If Len(Compiled) = 0 Then Compiled = ""




End Function

Sheet1

ABC
TypeNameCompiled_Types
CurdLemon
PieBanana
PieAppleSauce, Juice
SauceApplePie, Juice
JuiceApplePie, Sauce
JamStawberry
JuiceOrangeZest
ZestOrangeJuice
SodaGrape

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:68px;"><col style="width:68px;"><col style="width:68px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]7[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]8[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]9[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]10[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
C2=Compiled($B$2:$B$10)
C3=Compiled($B$2:$B$10)
C4=Compiled($B$2:$B$10)
C5=Compiled($B$2:$B$10)
C6=Compiled($B$2:$B$10)
C7=Compiled($B$2:$B$10)
C8=Compiled($B$2:$B$10)
C9=Compiled($B$2:$B$10)
C10=Compiled($B$2:$B$10)

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0
Neil, that worked brilliantly. Thank you so much for the help, I never would have worked that one out.
 
Upvote 0
If you use 2016 then maybe
=IF(COUNTIF($B$2:$B$10,$B2)=1,"",TEXTJOIN(",",TRUE,IF($B$2:$B$10=$B2,IF(ROW($B$2:$B$10)<>ROW(),$A$2:$A$10,""),"")))

Entered with CTRl+SHIFT+ENTER

Just to show that a formula can do it, with 40,000 rows, it might choke though :)
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

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