Index match within a delimited cell

kcmuppet

Active Member
Joined
Nov 2, 2005
Messages
437
Office Version
  1. 365
Platform
  1. Windows
Hi

I'm trying convert a variable list of strings within a table column into corresponding codes - a kind of Index Match within each cell, in which the values are separated with a delimiter (comma).

What's the best way to get the output in column F below? (I'm limited to Excel 2010 functions, and the tables are on different sheets, so I'm hoping to use structured references).


Scratch Book2.xlsx
BCDEF
3tbl_Lookuptbl_Convert
4
5StringsCodeInputOutput
6Some text 1F Some text 1, Some text 5, Some text 13, Some text 16F, B, E, Q
7Some text 2G Some text 2, Some text 6G, F
8Some text 3M Some text 3M
9Some text 4N Some text 4, Some text 13, Some text 1N, E, F
10Some text 5B
11Some text 6F
12Some text 7J
13Some text 8S
14Some text 9L
15Some text 10C
16Some text 11I
17Some text 12O
18Some text 13E
19Some text 14D
20Some text 15P
21Some text 16Q
22Some text 17H
23Some text 18R
24Some text 19H
25Some text 20J
26Some text 21K
27Some text 22999
28Some text 23G
29Some text 24A
30Some text 25888
Sheet3
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I suppose using Power Query with the Convert table I could
1. Add an Index column
2. Split the Input column into rows with custom delimeter ", ",
3. merge a Lookup table using a Left outer join type,
4. Expand selecting only the Code column
5. re Group by the Index column

...but I'd prefer to keep it all in Excel if it's possible...

Any tips greatly appreciated
 
Upvote 0
Hi kcmuppet,

I need to perform an Index Match analogous to the problem you outline above. Did you happen to figure out a solution?

Thanks.

dcuser
 
Upvote 0
@kcmuppet are you still using 2010? If so, try the following UDF in a standard module:

VBA Code:
Function kcmuppet(convert As Range, look As Range) As String
    Dim temp, i As Long, s As String
    temp = Split(convert, ",")
    On Error Resume Next
    For i = LBound(temp) To UBound(temp)
        s = s & ", " & Trim(Application.WorksheetFunction.VLookup(Trim(temp(i)), look, 2, 0))
    Next i
    On Error GoTo 0
    kcmuppet = Mid(s, 3)
End Function

Used like this (note the absolute range reference):
Book1
BCDEF
5StringsCodeInputOutput
6Some text 1F Some text 1, Some text 5, Some text 13, Some text 16F, B, E, Q
7Some text 2G Some text 2, Some text 6G, F
8Some text 3M Some text 3M
9Some text 4N Some text 4, Some text 13, Some text 1N, E, F
10Some text 5B
11Some text 6F
12Some text 7J
13Some text 8S
14Some text 9L
15Some text 10C
16Some text 11I
17Some text 12O
18Some text 13E
19Some text 14D
20Some text 15P
21Some text 16Q
22Some text 17H
23Some text 18R
24Some text 19H
25Some text 20J
26Some text 21K
27Some text 22999
28Some text 23G
29Some text 24A
30Some text 25888
Sheet1
Cell Formulas
RangeFormula
F6:F9F6=kcmuppet(E6,$B$6:$C$30)
 
Upvote 0
Try this

Excel Formula:
=LET(input,TEXTSPLIT(E3,", "),lkp,XLOOKUP(input,$B$3:$B$27,C$3:C$27,""),TEXTJOIN(", ",,lkp))

1708305181713.png
 
Upvote 0
@kevin9999
Not sure if you noticed but kcmuppet's question is over 3 years old.

@dcuser
Welcome to the MrExcel board!

If you wish to use the structured references of a formal table like the original question then try this version. It would automatically expand/contract if the tables change size.
I have included two options. The first if tbl_Lookup does only have two columns. The second if tbl_Lookup has more than two columns.

kcmuppet.xlsm
BCDEFG
3tbl_Lookuptbl_Convert
4
5StringsCodeInputOutput 1Output 2
6Some text 1F Some text 1, Some text 5, Some text 13, Some text 16F , B , E, QF , B , E, Q
7Some text 2G Some text 2, Some text 6G , F G , F
8Some text 3M Some text 3M M
9Some text 4N Some text 4, Some text 13, Some text 1N , E, F N , E, F
10Some text 5B
11Some text 6F
12Some text 7J
13Some text 8S
14Some text 9L
15Some text 10C
16Some text 11I
17Some text 12O
18Some text 13E
19Some text 14D
20Some text 15P
21Some text 16Q
22Some text 17H
23Some text 18R
24Some text 19H
25Some text 20J
26Some text 21K
27Some text 22999
28Some text 23G
29Some text 24A
30Some text 25888
Sheet1
Cell Formulas
RangeFormula
F6:F9F6=TEXTJOIN(", ",1,VLOOKUP(TEXTSPLIT([@Input],", "),tbl_Lookup,2,0))
G6:G9G6=TEXTJOIN(", ",1,XLOOKUP(TEXTSPLIT([@Input],", "),tbl_Lookup[Strings],tbl_Lookup[Code]))
 
Upvote 0
Solution
Thank you all for posting your solutions! I will give them a shot tomorrow at work. Cheers.
 
Upvote 0

Forum statistics

Threads
1,215,594
Messages
6,125,723
Members
449,255
Latest member
whatdoido

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