Vlookup with strings

jgopalk

New Member
Joined
Jun 14, 2011
Messages
26
Hi there,

I tried lot to fix this. But I couldn't make it up. Kindly guide me in this.

I have keywords with few strings. I need to get those words too by vlookup.

For example:
Table: 1 (Reference sheet)
AppleFruit
OrangeFruit
Ladies fingerVegetable
CarrotVegetable
BananaFruit
JasminFlower

<tbody>
</tbody>



Table: 2 (My question)

Apple | Orange | Banana
Apple | Jasmine
Carrot
Apple
Ladies finger; Orange

<tbody>
</tbody>

Table: 3 (outcome)

Apple | Orange | BananaFruits & Fruits & Fruits
Apple | Jasmine Fruits & Flower
Carrot Vegetable
Apple Fruit
Ladies finger; OrangeVegetable & Fruit

<tbody>
</tbody>

Here, already I have Table 1 with ~ 20000 keywords. I have “Table 2” to be filled like “Table 3”. I will have maximum of two strings. One is “ | “ and next is “ ; ”.

For single keyword, I know we can directly apply Vlookup. But this case of stings how can we proceed further?

Hope I have explained my requirement clearly. Kindly let me know if you have any further questions.

My extreme thanks in advance.

Gopal
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You say
I will have maximum of two strings. One is “ | “ and next is “ ; ”.

Could you please clarify what you mean by that? Do you mean you will have three (not two) strings "Apple | Orange | Banana" or are you referring to 'Ladies finger' which is a two word keyword or are you referring to that you will have only two different type of string separators?

Also, I see a space before and after the "|" is there not a space before the ";" but not after it?
 
Last edited:
Upvote 0
Thanks for your reply and sorry for the confusion.

Could you please clarify what you mean by that? Do you mean you will have three (not two) strings "Apple | Orange | Banana"

Here I might get multiple vertical bars ("|") or multiple semi colons (";") in a single cell. These types of special characters splits the words.

are you referring to 'Ladies finger' which is a two word keyword or are you referring to that you will have only two different type of string separators?

I might get "one word" or "two words" or multiple word keywords. There is no restriction in that. Just an example I have given these.

Also, I see a space before and after the "|" is there not a space before the ";" but not after it?

There will not any space between bars and semi colons (|, ;).

Thanks again for your questions. Hope I have clarified your doubts. Kindly check for any solution. There is no need to fix this by Vlook we may go with any other formula too. But kindly avoid Macros, which I am currently using.

Thank you.
Gopal
 
Upvote 0
If you are on a 2016 system, try the following set up:

Row\Col
A​
B​
C​
D​
E​
1​
2​
Apple Fruit Apple | Orange | BananaFruit & Fruit & Fruit
3​
Orange Fruit Apple | JasmineFruit & Flower
4​
Ladies finger Vegetable CarrotVegetable
5​
Carrot Vegetable AppleFruit
6​
Banana Fruit Ladies finger; OrangeFruit & Vegetable
7​
Jasmin Flower

In E2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN(" & ",TRUE,IF(ISNUMBER(SEARCH($A$2:$A$7,$D2)),$B$2:$B$7,""))
 
Upvote 0
Thanks all for your kind reply.

@Azumi: I could use your formula for my required. That is what i required. That is excellent Azumi. But, sheet is very slow when i using it in my system. I it is due to huge size of the formula? It would be great if you would reply for this.

@Aladin: Yours looks cool. But I am using 2013. So couldnt get answer. Could you please make it for 2013?

Once again thanks all.

Gopal
 
Upvote 0
[...]

@Aladin: Yours looks cool. But I am using 2013. So couldnt get answer. Could you please make it for 2013?

[...]

In E2 control+shift+enter, not just enter, and copy down:

=REPLACE(aconcat(IF(ISNUMBER(SEARCH($A$2:$A$7,$D2))," & "&$B$2:$B$7,"")),1,3,"")

For this formula to work, add the following <acronym title="visual basic for applications">VBA</acronym> code to your workbook as a module, using Alt+F11...

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
 
Upvote 0
Thanks all for your reply and apologies for late reply. I was in limited net access area.

Formulas you have given is working good. But, when the different keywords comes in the list it should shows as N/A. For example, potato is not the list. So if comes in the Column D, result should shows as N/A.

Could you please check whether is this is possible to include in VBA/Macro code?

Thanks again.

Gopal
 
Upvote 0
Thanks all for your reply and apologies for late reply. I was in limited net access area.

Formulas you have given is working good. But, when the different keywords comes in the list it should shows as N/A. For example, potato is not the list. So if comes in the Column D, result should shows as N/A.

...

How do you mean?
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,166
Members
448,870
Latest member
max_pedreira

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