Keyword lookup from a list of keywords in a column of text descriptions

swmicros

New Member
Joined
Jan 12, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have an Excel database of invoice data with a text column for the description of the work performed. I need to identify (T/F in a column?) any invoice that has any keywords from a list in the description column. I have not yet created the list of keywords as I am not sure how they should be arranged, your suggestion will be welcomed.

How would I do that?

Simplified version of what I am after:

Book4
ABCDE
1InvoiceDescriptionT/FKeyword list
215000Sorted apples and put into boxes for BillFregister, cash, bagged, bag, bagging
315001Worked the register for Suzy, who was out today for vacation.T
415002Worked produce with BillF
515003Stocked shelves during night shift to help KenF
615004helped at the cash register as per BobT
715005brought in carts from parking lot on FridayF
815006Stocked produce shelves with JavierF
915007bagging at register, with SuzyT
1015008Filled in in bakery dept on Sat, with MaryF
Sheet1
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi & Welcome to Mr.Excel

Does this work

VBA Code:
=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)

Book1
ABCD
1InvoiceDescriptionT/F
215000Sorted apples and put into boxes for BillFFALSE
315001Worked the register for Suzy, who was out today for vacation.TTRUE
415002Worked produce with BillFFALSE
515003Stocked shelves during night shift to help KenFFALSE
615004helped at the cash register as per BobTTRUE
715005brought in carts from parking lot on FridayFFALSE
815006Stocked produce shelves with JavierFFALSE
915007bagging at register, with SuzyTTRUE
1015008Filled in in bakery dept on Sat, with MaryFFALSE
Sheet2
Cell Formulas
RangeFormula
D2:D10D2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)
Dynamic array formulas.


Edit: This option might not work as well as I expected. Looking for a more robust solution
 
Last edited:
Upvote 0
Hi & Welcome to Mr.Excel

Does this work

VBA Code:
=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)

Book1
ABCD
1InvoiceDescriptionT/F
215000Sorted apples and put into boxes for BillFFALSE
315001Worked the register for Suzy, who was out today for vacation.TTRUE
415002Worked produce with BillFFALSE
515003Stocked shelves during night shift to help KenFFALSE
615004helped at the cash register as per BobTTRUE
715005brought in carts from parking lot on FridayFFALSE
815006Stocked produce shelves with JavierFFALSE
915007bagging at register, with SuzyTTRUE
1015008Filled in in bakery dept on Sat, with MaryFFALSE
Sheet2
Cell Formulas
RangeFormula
D2:D10D2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)
Dynamic array formulas.


Edit: This option might not work as well as I expected. Looking for a more robust solution
To be clear, Col C in my example is where this unknown formula should go, it is NOT part of the data. Sorry, didn't make that clear. Also the list of keywords can be whatever format is best suited for the task. I am thinking the TEXTSPLIT command may be unnecessary if the keyword list is a column instead of a comma delimited cell, correct?
 
Upvote 0
In that case we would just place the formula in Column C instead.

Book1
ABC
1InvoiceDescriptionT/F
215000Sorted apples and put into boxes for BillFALSE
315001Worked the register for Suzy, who was out today for vacation.TRUE
415002Worked produce with BillFALSE
515003Stocked shelves during night shift to help KenFALSE
615004helped at the cash register as per BobTRUE
715005brought in carts from parking lot on FridayFALSE
815006Stocked produce shelves with JavierFALSE
915007bagging at register, with SuzyTRUE
1015008Filled in in bakery dept on Sat, with MaryFALSE
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)
Dynamic array formulas.


However as I put on my Edit above, this formula is not truly accurate. If one of the descriptions were to include cash, bagged, bag, or bagging but does not include the word 'Register" it would return a False. Like here where the second to last row says "Bagging the cash, with Suzy". I assume you would still want this row to return TRUE:

Book1
ABC
1InvoiceDescriptionT/F
215000Sorted apples and put into boxes for BillFALSE
315001Worked the register for Suzy, who was out today for vacation.TRUE
415002Worked produce with BillFALSE
515003Stocked shelves during night shift to help KenFALSE
615004helped at the cash register as per BobTRUE
715005brought in carts from parking lot on FridayFALSE
815006Stocked produce shelves with JavierFALSE
915007bagging the cash, with SuzyFALSE
1015008Filled in in bakery dept on Sat, with MaryFALSE
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)
Dynamic array formulas.
 
Upvote 0
In that case we would just place the formula in Column C instead.

Book1
ABC
1InvoiceDescriptionT/F
215000Sorted apples and put into boxes for BillFALSE
315001Worked the register for Suzy, who was out today for vacation.TRUE
415002Worked produce with BillFALSE
515003Stocked shelves during night shift to help KenFALSE
615004helped at the cash register as per BobTRUE
715005brought in carts from parking lot on FridayFALSE
815006Stocked produce shelves with JavierFALSE
915007bagging at register, with SuzyTRUE
1015008Filled in in bakery dept on Sat, with MaryFALSE
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)
Dynamic array formulas.


However as I put on my Edit above, this formula is not truly accurate. If one of the descriptions were to include cash, bagged, bag, or bagging but does not include the word 'Register" it would return a False. Like here where the second to last row says "Bagging the cash, with Suzy". I assume you would still want this row to return TRUE:

Book1
ABC
1InvoiceDescriptionT/F
215000Sorted apples and put into boxes for BillFALSE
315001Worked the register for Suzy, who was out today for vacation.TRUE
415002Worked produce with BillFALSE
515003Stocked shelves during night shift to help KenFALSE
615004helped at the cash register as per BobTRUE
715005brought in carts from parking lot on FridayFALSE
815006Stocked produce shelves with JavierFALSE
915007bagging the cash, with SuzyFALSE
1015008Filled in in bakery dept on Sat, with MaryFALSE
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($K$2,", "),B2:B10)),1)
Dynamic array formulas.

MrExcelTestExample.xlsx
ABCD
1InvoiceDescriptionKeyword MatchKeyword List
215000Sorted apples and put into boxes for BillFALSEcash, register, bagged, bagging
315001Worked the register for Suzy, who was out today for vacation.FALSE
415002Worked produce with BillFALSE
515003Stocked shelves during night shift to help KenFALSE
615004helped at the cash register as per BobTRUE
715005brought in carts from parking lot on FridayFALSE
815006Stocked produce shelves with JavierFALSE
915007bagging at register, with SuzyFALSE
1015008Filled in in bakery dept on Sat, with MaryFALSE
Sheet1
Cell Formulas
RangeFormula
C2:C10C2=CHOOSECOLS(ISNUMBER(SEARCH(TEXTSPLIT($D$2,", "),B2:B10)),1)
Dynamic array formulas.


You are correct, multiple matches should still result in TRUE. However, I can't seem to get the same results as you. It it is only matching on the keyword cash, not any any of the others in the list.
 
Upvote 0
Maybe list your keywords in a column.

Book5
ABCDE
1InvoiceDescriptionT/FKeyword list
215000Sorted apples and put into boxes for BillFregister
315001Worked the register for Suzy, who was out today for vacation.T cash
415002Worked produce with BillF bagged
515003Stocked shelves during night shift to help KenF bag
615004helped at the cash register as per BobT bagging
715005brought in carts from parking lot on FridayF
815006Stocked produce shelves with JavierF
915007bagging at register, with SuzyT
1015008Filled in in bakery dept on Sat, with MaryF
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=IF(SUM(--ISNUMBER(SEARCH($E$2:$E$6,$B2)))>0,"T","F")
C10C10=IF(SUM(--ISNUMBER(SEARCH($E$2:$E$6,B10)))>0,"T","F")
 
Upvote 0
In my post#6 above just copy or drag the formula in C2 down. Formula in C10 copied over from a test I did (it's the same as C2).
 
Upvote 0
I am thinking the TEXTSPLIT command may be unnecessary if the keyword list is a column instead of a comma delimited cell, correct?
Correct and I agree with @AhoyNC that the column list would be a better idea.

However, if you are looking for key words then I think you will need a bit more than has been suggested. For example, I have used the post #6 suggestion in column C below and to me the results in rows 11:13 may not be correct because the formula has checked for "text strings" not for "words". If you are looking for "words" then you could try the column D formula.

24 01 13.xlsm
BCDE
1DescriptionT/FKeyword list
2Sorted apples and put into boxes for BillFFregister
3Worked the register for Suzy, who was out today for vacation.TTcash
4Worked produce with BillFFbagged
5Stocked shelves during night shift to help KenFFbag
6helped at the cash register as per BobTTbagging
7brought in carts from parking lot on FridayFF
8Stocked produce shelves with JavierFF
9bagging at register, with SuzyTT
10Filled in in bakery dept on Sat, with MaryFF
11Registered my hours workedTF
12Restocked the cashew binTF
13Displayed new handbagsTF
Keywords
Cell Formulas
RangeFormula
C2:C13C2=IF(SUM(--ISNUMBER(SEARCH($E$2:$E$6,$B2)))>0,"T","F")
D2:D13D2=IF(COUNT(SEARCH(" "&E$2:E$6&" "," "&B2&" "))>0,"T","F")
 
Upvote 0
Solution
Peter - Good catch, yes that is ultimately what I will want a whole word type search, not a string search - thanks.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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