Search for TEXT in a column and return a value of the next columns

n0n0n0

New Member
Joined
Jul 13, 2017
Messages
19
Dear all excel experts,

I have tried to use INDEX and MATCH yet still can't figure this out:


Table 1:
[TABLE="width: 749"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Remark[/TD]
[TD]
Currency Amt[/TD]
[/TR]
[TR]
[TD]Vchr# 100799, Pymt ID# flliqtaxcc0558902062, Supplier: Dept. of Bus. & Pro. Regulation, Cash Acct - A/P Acct[/TD]
[TD="align: right"]67,999.13[/TD]
[/TR]
[TR]
[TD]Vchr# 99059, Pymt ID# 445193, Supplier: Caribbean Distillers, LLC, Cash Acct - A/P Acct[/TD]
[TD="align: right"]65,707.75[/TD]
[/TR]
[TR]
[TD]Vchr# 99051, Pymt ID# w/VinDore1875/bf19, Supplier: VIN DORÉ 24K[/TD]
[TD="align: right"]64,800.00[/TD]
[/TR]
[TR]
[TD]Vchr# 99537, Pymt ID# 445214, Supplier: Caribbean Distillers, LLC, Cash Acct - A/P Acct[/TD]
[TD="align: right"]64,134.50[/TD]
[/TR]
[TR]
[TD]Vchr# 99495, Pymt ID# 445207, Supplier: Sugarlands Distilling Company, Cash Acct - A/P Acct[/TD]
[TD="align: right"]47,340.00[/TD]
[/TR]
[TR]
[TD]Vchr# 102094, Supplier: Sugarlands Distilling Company, A/P Acct - Exp Accts[/TD]
[TD="align: right"]22,371.00[/TD]
[/TR]
[TR]
[TD]Vchr# 99853, Pymt ID# w/royalwine/810111, Supplier: Royal Wine Corporation[/TD]
[TD="align: right"]15,167.50[/TD]
[/TR]
[TR]
[TD]Vchr# 99058, Pymt ID# 445197, Supplier: Sugarlands Distilling Company, Cash Acct - A/P Acct[/TD]
[TD="align: right"]11,700.00[/TD]
[/TR]
[TR]
[TD]Vchr# 99440, Pymt ID# 445199, Supplier: Bridge / SG WORLDWIDE[/TD]
[TD="align: right"]11,460.00[/TD]
[/TR]
</tbody>[/TABLE]


Table 2:

[TABLE="width: 287"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Cargo Import Brokers Inc.[/TD]
[/TR]
[TR]
[TD]Frank-lin Distillers[/TD]
[/TR]
[TR]
[TD]J.F. Hillebrand USA Inc.[/TD]
[/TR]
[TR]
[TD]JF Hillebrand USA[/TD]
[/TR]
[TR]
[TD]M.S. Walker[/TD]
[/TR]
[TR]
[TD]T-MOBILE[/TD]
[/TR]
[TR]
[TD]Aiko Importers Inc[/TD]
[/TR]
[TR]
[TD]PARK STREET IMPORTS / BRICKELL WINES[/TD]
[/TR]
[TR]
[TD]Camrose Trading[/TD]
[/TR]
[TR]
[TD]Command Transportation LLC

I'm trying to search for the name on Table 2 in Column Remark of Table 1, and if there's a match, then return the total value in Column Currency Amount next to Column Name of Table 2.

Thank you very much for your advice and helps


[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Assuming your table 1 is in A1:B10

And I have table 2 in A15:A25, I added 1 line so there would be a match.
In B15:
=IFERROR(VLOOKUP("*"&A15&"*",$A$2:$B$10,2,0),"")
Copy down.


Excel 2010
AB
1RemarkCurrency Amt
2Vchr# 100799, Pymt ID# flliqtaxcc0558902062, Supplier: Dept. of Bus. & Pro. Regulation, Cash Acct - A/P Acct67,999.13
3Vchr# 99059, Pymt ID# 445193, Supplier: Caribbean Distillers, LLC, Cash Acct - A/P Acct65,707.75
4Vchr# 99051, Pymt ID# w/VinDore1875/bf19, Supplier: VIN DOR 24K64,800.00
5Vchr# 99537, Pymt ID# 445214, Supplier: Caribbean Distillers, LLC, Cash Acct - A/P Acct64,134.50
6Vchr# 99495, Pymt ID# 445207, Supplier: Sugarlands Distilling Company, Cash Acct - A/P Acct47,340.00
7Vchr# 102094, Supplier: Sugarlands Distilling Company, A/P Acct - Exp Accts22,371.00
8Vchr# 99853, Pymt ID# w/royalwine/810111, Supplier: Royal Wine Corporation15,167.50
9Vchr# 99058, Pymt ID# 445197, Supplier: Sugarlands Distilling Company, Cash Acct - A/P Acct11,700.00
10Vchr# 99440, Pymt ID# 445199, Supplier: Bridge / SG WORLDWIDE11,460.00
11
12
13
14
15Cargo Import Brokers Inc. 
16Frank-lin Distillers 
17J.F. Hillebrand USA Inc. 
18JF Hillebrand USA 
19M.S. Walker 
20T-MOBILE 
21Aiko Importers Inc 
22PARK STREET IMPORTS / BRICKELL WINES 
23Camrose Trading 
24Command Transportation LLC 
25Sugarlands Distilling Company47340.00
Sheet1
Cell Formulas
RangeFormula
B15=IFERROR(VLOOKUP("*"&A15&"*",$A$2:$B$10,2,0),"")
B16=IFERROR(VLOOKUP("*"&A16&"*",$A$2:$B$10,2,0),"")
B17=IFERROR(VLOOKUP("*"&A17&"*",$A$2:$B$10,2,0),"")
B18=IFERROR(VLOOKUP("*"&A18&"*",$A$2:$B$10,2,0),"")
B19=IFERROR(VLOOKUP("*"&A19&"*",$A$2:$B$10,2,0),"")
B20=IFERROR(VLOOKUP("*"&A20&"*",$A$2:$B$10,2,0),"")
B21=IFERROR(VLOOKUP("*"&A21&"*",$A$2:$B$10,2,0),"")
B22=IFERROR(VLOOKUP("*"&A22&"*",$A$2:$B$10,2,0),"")
B23=IFERROR(VLOOKUP("*"&A23&"*",$A$2:$B$10,2,0),"")
B24=IFERROR(VLOOKUP("*"&A24&"*",$A$2:$B$10,2,0),"")
B25=IFERROR(VLOOKUP("*"&A25&"*",$A$2:$B$10,2,0),"")
 
Upvote 0
Thank you for your quick response ans solution. It works well, except for one detail that I forgot to add in the original post.
If you notice that in some name will have more than one result, i.e "Sugarlands Distilling Company", and in that case, won't the formula only return the 1st result instead of all results?
Is there a way to return the total of all results?

Thank you very much for your help.
 
Upvote 0
In B15:
=SUM(IF(ISNUMBER(SEARCH(A15,$A$2:$A$10)),$B$2:$B$10))

Confirm with CTRL-SHIFT-ENTER rather than just Enter.
Copy down.


Excel 2010
AB
1RemarkCurrency Amt
2Vchr# 100799, Pymt ID# flliqtaxcc0558902062, Supplier: Dept. of Bus. & Pro. Regulation, Cash Acct - A/P Acct67,999.13
3Vchr# 99059, Pymt ID# 445193, Supplier: Caribbean Distillers, LLC, Cash Acct - A/P Acct65,707.75
4Vchr# 99051, Pymt ID# w/VinDore1875/bf19, Supplier: VIN DOR 24K64,800.00
5Vchr# 99537, Pymt ID# 445214, Supplier: Caribbean Distillers, LLC, Cash Acct - A/P Acct64,134.50
6Vchr# 99495, Pymt ID# 445207, Supplier: Sugarlands Distilling Company, Cash Acct - A/P Acct47,340.00
7Vchr# 102094, Supplier: Sugarlands Distilling Company, A/P Acct - Exp Accts22,371.00
8Vchr# 99853, Pymt ID# w/royalwine/810111, Supplier: Royal Wine Corporation15,167.50
9Vchr# 99058, Pymt ID# 445197, Supplier: Sugarlands Distilling Company, Cash Acct - A/P Acct11,700.00
10Vchr# 99440, Pymt ID# 445199, Supplier: Bridge / SG WORLDWIDE11,460.00
11
12
13
14
15Cargo Import Brokers Inc.0.00
16Frank-lin Distillers0.00
17J.F. Hillebrand USA Inc.0.00
18JF Hillebrand USA0.00
19M.S. Walker0.00
20T-MOBILE0.00
21Aiko Importers Inc0.00
22PARK STREET IMPORTS / BRICKELL WINES0.00
23Camrose Trading0.00
24Command Transportation LLC0.00
25Sugarlands Distilling Company81,411.00
Sheet1
Cell Formulas
RangeFormula
B15{=SUM(IF(ISNUMBER(SEARCH(A15,$A$2:$A$10)),$B$2:$B$10))}
B16{=SUM(IF(ISNUMBER(SEARCH(A16,$A$2:$A$10)),$B$2:$B$10))}
B17{=SUM(IF(ISNUMBER(SEARCH(A17,$A$2:$A$10)),$B$2:$B$10))}
B18{=SUM(IF(ISNUMBER(SEARCH(A18,$A$2:$A$10)),$B$2:$B$10))}
B19{=SUM(IF(ISNUMBER(SEARCH(A19,$A$2:$A$10)),$B$2:$B$10))}
B20{=SUM(IF(ISNUMBER(SEARCH(A20,$A$2:$A$10)),$B$2:$B$10))}
B21{=SUM(IF(ISNUMBER(SEARCH(A21,$A$2:$A$10)),$B$2:$B$10))}
B22{=SUM(IF(ISNUMBER(SEARCH(A22,$A$2:$A$10)),$B$2:$B$10))}
B23{=SUM(IF(ISNUMBER(SEARCH(A23,$A$2:$A$10)),$B$2:$B$10))}
B24{=SUM(IF(ISNUMBER(SEARCH(A24,$A$2:$A$10)),$B$2:$B$10))}
B25{=SUM(IF(ISNUMBER(SEARCH(A25,$A$2:$A$10)),$B$2:$B$10))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thank you very much. It works like a charm.

I didn't understand the formula 100%. If you have time, would you please explain it for me so I'll be able to apply the concept in the future?

Thank you.
 
Upvote 0
Oh yeah!!! That does make sense now. Thank you, Eric!

Quick question. Let's use the same example above.
If I want to do conditional formatting to highlight rows of A2:A10 that contains the text of A15:A25.
For example, Row A6, A7, A9 would be highlighted while other won't be because none of A15:A25 are in A2:A10, except for Sugarlands Distilling Company.

Thank you for your help and wisdom.


 
Upvote 0
Sure, select A2:B10. Click Conditional Formatting > New Rule > Use a Formula > and enter:

=LOOKUP(2^16,FIND($A$15:$A$25,$A2))

and select your fill color.

Glad we could help!
 
Upvote 0
Thank you again for your help!

Would you mind explain to me the purpose of 2^16 in the LOOKUP function, please? I would like to understand to be able to make adjustment if necessary.

Thank you.
 
Upvote 0
Sure. The FIND looks for each of the values in A15:A25 within the value of A2. It returns the location within A2 for each phrase. If it's not found, it returns #VALUE ! So for A2, none of A15:A25 is found, so you get the array {#VALUE !, #VALUE !, ...}. If we're looking at cell A6, the array would be: {#VALUE !, #VALUE !, ... #VALUE !, 41}, because Sugarlands Distilling Company (A25) is found in position 41 of A6.

Now LOOKUP will scan through the array looking for 2^16. The maximum number of characters allowed in a cell is 2^15. So if I look for 2^16, I'll never find it. But another feature of LOOKUP is that if it can't find the number you're looking for (and we've rigged it so it won't), it will return the last number in the array (ignoring errors), or 41.

So on the 2 examples, LOOKUP won't find any matches for A2, so it returns #N/A. On the second example, it finds 41. And finally, the way Conditional Formatting works, if the result of a formula is 0 or an error, it does not trigger the formatting. If the result of the formula is non-zero, like the 41, it triggers the formatting.

One other thought is that you might want to use SEARCH instead of FIND, since SEARCH isn't case-sensitive.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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