Vlookup Query

marsh_win

New Member
Joined
Mar 14, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi Team,

Need support.

I have 2 sets of Data

One set of Data is as below
CodeValue
ZS-D*
50%​
FL-**
25%​
ZV-*
30%​
ZV-K*
25%​
FL
40%​


In another excel sheet i have a value ZS-DR. for this code i need excel to pick the value 50% from the above table.

How can this be possible using vookup.

Appreciate your support
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
a few ways to do that
does this work
=INDEX($B$2:$B$101,MATCH(1,COUNTIF(E2,"*"&A$2:$A$101&"*"),0))

Book9
ABCDEF
1CodeValue
2ZS-D*50%ZS-DL50%
3FL-**25%FL-12325%
4ZV-*30%FL40%
5ZV-K*25%#N/A
6FL40%
Sheet1
Cell Formulas
RangeFormula
F2:F5F2=INDEX($B$2:$B$101,MATCH(1,COUNTIF(E2,"*"&A$2:$A$101&"*"),0))
 
Upvote 0
a few ways to do that
does this work
=INDEX($B$2:$B$101,MATCH(1,COUNTIF(E2,"*"&A$2:$A$101&"*"),0))

Book9
ABCDEF
1CodeValue
2ZS-D*50%ZS-DL50%
3FL-**25%FL-12325%
4ZV-*30%FL40%
5ZV-K*25%#N/A
6FL40%
Sheet1
Cell Formulas
RangeFormula
F2:F5F2=INDEX($B$2:$B$101,MATCH(1,COUNTIF(E2,"*"&A$2:$A$101&"*"),0))
Thanks etaf.. But one point.

for FL-123 the VLOOKUP should not revert with 25% as the main table array it can be only FL-** (Max of 2 digits after FL-
 
Upvote 0
for FL-123 the VLOOKUP should not revert with 25% as the main table array it can be only FL-** (Max of 2 digits after FL-
ok, so will the value in the lookup ever be more than 2 digits ... if so then it will not occur
or do we need to test the entry and make sure it only has 2 digits after the entry

can you give a range of entries that are possible - as all you said in first post was to lookup

i have a value ZS-DR. for this code i need excel to pick the value 50% from the above table.
so i was just checking any possible other value
 
Upvote 0
Than
ok, so will the value in the lookup ever be more than 2 digits ... if so then it will not occur
or do we need to test the entry and make sure it only has 2 digits after the entry

can you give a range of entries that are possible - as all you said in first post was to lookup


so i was just checking any possible other value
Thanks for taking time. Let me add more data. Assume below is the target Data

CodeRange
FL
5%​
FL-**
10%​
MG-C
15%​
MG-C*
20%​
MV-*
25%​
MV-K*
30%​
MV-O
35%​
NS-B
40%​
NS-C
45%​
NS-D
50%​
NS-D*
55%​
NV-*
60%​
NV-K*
65%​
RS-D
70%​
RS-D*
75%​
RV-*
80%​
RV-K*
85%​
ZG-T
90%​
ZG-T*
95%​
ZS-D
100%​
ZS-D*
105%​
ZV-*
110%​
ZV-K*
115%​


* indicate that a code can be added after the value. In that case for the below search results the excepted VLOOKUP needs to be


VlookupExpected vlookup results
FL-DN/A
FL-DT
10%​
FL
5%​
MV-K
25%​
MV-KT
30%​
MV-KTON/A
NS-D
50%​
NS-DT
55%​
NS-OTN/A
 
Upvote 0
so is that all the possible combinations of lookup range *
2 , 4 & 5 characters length
and the * determine how many characters are allowed
so you wont have more than XX-**
And a - always appears with the * items

as you have for example
MG-C
and
MG-C*

Can be anything with MG-C - on its own or with 1 extra character
BUT if you only had
MG-C*
in the list - then MG-C would not be allowed , nor would MG-CAA


so FL-** in the lookup range
means when looked up value has to match the length of 2 characters after the -
so only 5 characters will be allowed

FL-12 - is OK
FL-1 is not
FL-123 is not
as the lookup range value is FL-** - so must have 2 characters after the - to be valid lookup

BUT as FL is in the lookup range , then only FL will match with that

not sure i have an answer for that combination - hopefully another member may have a solution - i'll have to have a think
 
Upvote 0
I thought you asked for Power Query

First Source line is your codes table
Second line is the table which contains the percentages.

Power Query:
let
    SourceCodes = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    SourcePerc = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    pList = SourcePerc[Value],
    perc = Table.AddColumn(SourceCodes, "Perc", each
      pList
      {
         List.PositionOf(SourcePerc[Code],
            Record.Field(
               List.Accumulate(SourcePerc[Code],[cnt=0,code=0], (s,c)=>
                    let
                        t = List.Count(Text.PositionOfAny(c, Text.ToList(_[Code]),Occurrence.All))  
                    in
                        if Text.Length(_[Code]) = Text.Length(c) and t = Text.Length(Text.Replace(c,"*",""))
                          then [cnt=t,code= c]
                        else s
                ),"code"
             )
          )
       }
    )
in
     perc

1710414417081.png
 
Upvote 0
Give this a try:

20240314 Reverse Wild Card Match marsh_win.xlsx
ABCDEF
1CodeRangeVlookupReturn Value
2FL5%FL-DNA
3FL-**10%FL-DT10%
4MG-C15%FL5%
5MG-C*20%MV-K25%
6MV-*25%MV-KT30%
7MV-K*30%MV-KTONA
8MV-O35%NS-D50%
9NS-B40%NS-DT55%
10NS-C45%NS-OTNA
11NS-D50%
12NS-D*55%
13NV-*60%
14NV-K*65%
15RS-D70%
16RS-D*75%
17RV-*80%
18RV-K*85%
19ZG-T90%
20ZG-T*95%
21ZS-D100%
22ZS-D*105%
23ZV-*110%
24ZV-K*115%
25
Sheet1
Cell Formulas
RangeFormula
F2:F10F2=IFNA(INDEX($B$1:$B$24,MATCH(1,MATCH(SUBSTITUTE($A$1:$A$24,"*","?"),E2,0),0),0),"NA")
 
Upvote 0

Forum statistics

Threads
1,215,236
Messages
6,123,799
Members
449,127
Latest member
Cyko

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