excel vba vlookup multiple values (1 Viewer)

Futurz

New member
Local time
Today, 07:34
Joined
Sep 17, 2021
Messages
26
Hi, I am looking for a simple vba for excel, to match a vlookup values mentioned in column 'E' and display the result in column 'F'
Given Index in Column 'B' and value in Column 'A'
Note : The attached file is a sample, but the actual data may be upto 100 rows...or more
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:34
Joined
Aug 30, 2003
Messages
36,125
There is no attachment. If memory serves, the index column must be to the left of the value column in a VLookup, though it's been a while.
 

Futurz

New member
Local time
Today, 07:34
Joined
Sep 17, 2021
Messages
26
Hi, Pbaldy,
I have reattached my xls file.
 

Attachments

  • vlookup.zip
    6.2 KB · Views: 276

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:34
Joined
Aug 30, 2003
Messages
36,125
This would appear to confirm my recollection that the index has to be to the left of the value, not the other way around:

 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,287
Use index()and Match() instead.
 

Futurz

New member
Local time
Today, 07:34
Joined
Sep 17, 2021
Messages
26
This would appear to confirm my recollection that the index has to be to the left of the value, not the other way around:

Dear Pbaldy,
It doesn't matter if we shift "index" to the left of "value". I just need the result as mentioned.
Could you please set the above attached file to get the desired "result" (through a vba code)
Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:34
Joined
Aug 30, 2003
Messages
36,125
Hopefully Gasman's suggestion works for you. I'm not that strong in Excel, I'd probably create a custom function or something.
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,287
Example 5 is your best bet.

However Vlookup only handles a single value in a cell, not a string of values, as you have in E5 ?
 

Isaac

Lifelong Learner
Local time
Yesterday, 23:34
Joined
Mar 14, 2017
Messages
8,777
Dear Pbaldy,
It doesn't matter if we shift "index" to the left of "value". I just need the result as mentioned.
Could you please set the above attached file to get the desired "result" (through a vba code)
Thanks.

use vlookup.
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,287
Isaac, the problem is the multiple values in a cell. Do you know a way to make VLookup() handle that?
How is that meant to work anyway?, which value do you want to search for? :(
All of them?, so each subsequent one overwrites the value of the previous search?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:34
Joined
Aug 30, 2003
Messages
36,125
I'm not the OP, but from the attachment each value in the lookup string gets its corresponding value returned in the return string. Concatenated lookup, concatenated result.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:34
Joined
May 7, 2009
Messages
19,241
here is a VBA alternative.
 

Attachments

  • vlookup.zip
    21.6 KB · Views: 270

Futurz

New member
Local time
Today, 07:34
Joined
Sep 17, 2021
Messages
26
Dear Arnelgp,
I thank you once again for your brilliant efforts.
My query is Solved
Thanks...
Dear Arnelgp,
There is a little inaccuracy in the result when I modified the index & value data..
Please have a look at the attached file.
Thanks
 

Attachments

  • Vlookup.zip
    13.8 KB · Views: 225

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:34
Joined
May 7, 2009
Messages
19,241
see the change on calling the function.
 

Attachments

  • Vlookup (1).zip
    14.8 KB · Views: 260

Isaac

Lifelong Learner
Local time
Yesterday, 23:34
Joined
Mar 14, 2017
Messages
8,777
Isaac, the problem is the multiple values in a cell. Do you know a way to make VLookup() handle that?

Oh -
Sorry, I don't usually download people's Excel attachments, as I tend to help those who will describe the problem in writing.

Is it like multiple lines separated by line breaks? Some left, right, find, and char() might work? Increase complexity to find 2nd, 3rd, 4th lines etc.
Same thing if we're talking about the returned value, I guess you'd have to vlookup the whole thing, then start wrapping it in more formulas to chunk it out.

If I still have no idea what is needed, feel free to ignore me :p
 

Users who are viewing this thread

Top Bottom