Lookup using a single cell with concatenated values and return values to a single cell as concatenated values

norwoodkd2001

New Member
Joined
Jun 30, 2015
Messages
10
I have a situation where we are asking users to provide the name or names of groups that can be assigned to an underwriting condition. They are to enter all the names that apply separated by a comma into one cell. I have a another tab that has the names and the associated ID's. I need to provide the ID's that relate to all the names entered in the group name cell to a single field separated by commas. Also not every condition will have multiple group names. Below is an example of the source sheet where the users are populating column B and column C being the expected outcome of the lookup and the sheet that contains the the Group Names and associated Group ID's.

Any help would be greatly appreciated!

1574697861447.png
1574698050523.png
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Not very user friendly and prone to human error. You want them to enter "Employment / Income, Purchase, Comments, DU, General" and expect them to type it 100% correctly?
What happens if they spell a Group name incorrectly?

Why not just provide them with a list where they can put a number 1 2 or 3 (Condition) against each list item?
 
Upvote 0
Not very user friendly and prone to human error. You want them to enter "Employment / Income, Purchase, Comments, DU, General" and expect them to type it 100% correctly?
What happens if they spell a Group name incorrectly?

Why not just provide them with a list where they can put a number 1 2 or 3 (Condition) against each list item?

You are correct it is not very user friendly but I am trying to make it a little easier for the user. The problem is the amount of data to be collected and limiting the amount of time to update the spreadsheet.

There will be over 200 rows of data (conditions) and the list of group names is actually over 35 not just the subset I presented in my screenshot.. This is for an upload to a 3rd party system and the vendor only wants the numeric values but it would be very difficult for a user to always refer to a chart on each condition to make sure they entered the correct numeric value and I need to make it easy for them to copy/paste so I didn't go with a drop down list.

I felt it was easier for them to type in the name because I can always correct for spelling errors but I wouldn't be able to identify if they keyed in a wrong number. I'm sure I will get some errors on the lookup until I correct the spelling errors but I'll be scrubbing the data before it goes the vendor anyway.

So based upon this....any solutions on how to do the lookup?
 
Upvote 0
What version of Xl will this be run on?
 
Upvote 0
That's a shame, it can be done very easily with TEXTJOIN, but you don't have that.
Would a VBA solution be ok, or does it need to be a formula?
 
Upvote 0
With data like

Book1
ABFGH
1County
215BedfordshireSurrey, Bristol24, 43
338BerkshireDevon, Essex, Kent5, 6, 18
443BristolKent, Wiltshire, Cumbria18, 17, 44
520BuckinghamshireWest Yorkshire14
640CambridgeshireDorset, Cornwall13, 46
739Cheshire
848City of London
946Cornwall
1035County Durham
1144Cumbria
1232Derbyshire
135Devon
1413Dorset
1537East Riding of Yorkshire
1641East Sussex
176Essex
1821Gloucestershire
1926Greater London
2022Greater Manchester
217Hampshire
2245Herefordshire
2325Hertfordshire
2428Isle of Wight
2518Kent
2610Lancashire
2711Leicestershire
288Lincolnshire
2929Merseyside
Data


VBA Code:
Sub norwoodkd()
    Dim Sp As Variant
    Dim i As Long
    Dim Cl As Range
    Dim txt As String
    
    With CreateObject("scripting.dictionary")
        For Each Cl In Range("B2", Range("B" & Rows.Count).End(xlUp))
            .Item(Cl.Value) = Cl.Offset(, -1).Value
        Next Cl
        For Each Cl In Range("G2", Range("G" & Rows.Count).End(xlUp))
            Sp = Split(Cl.Value, ", ")
            For i = 0 To UBound(Sp)
                If .exists(Sp(i)) Then txt = txt & .Item(Sp(i)) & ", "
            Next i
            Cl.Offset(, 1).Value = Left(txt, Len(txt) - 2)
            txt = ""
        Next Cl
    End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,371
Messages
6,124,529
Members
449,169
Latest member
mm424

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