Excel to find key words and paste the same in Criteria column

tinferns

Board Regular
Joined
Aug 18, 2009
Messages
150
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Team.. Need your help again. I believe it is possible for Excel to find key words as described by user and paste the same in the dedicated cell. And I also believe this can be done without using a Macro. Please help out on the below.. I prefer not to use Macro's if possible please.

Keyword and their expected output:

Key Words (NOT case sensitive): (This is just an example Key Word list.. actual one is approx. 20 items/values)Result
FlightFlight
FlightsFlight
TicketAir Ticket
Air TicketAir Ticket
Air TicketsAir Ticket
PNRPNR
PNR'sPNR
PNRsPNR

Below is an example (In some cases there are 2 key words used, Excel can choose the first key word in such cases)

DescriptionCriteriaExpected Result
ABC bought a flight ticket paying XXX amountFlight
XYZ bought 3 Air Tickets paying xxx amountAir Ticket
CDE bought 1 Air Ticket vide PNR - XXXXXXXAir Ticket

Hope to hear from you soon. Thanks.. M
 
Thanks a trillion Peter SSs. The above formula worked. And it worked just fine. Am using the Lookup and Search option. Thanks again

@ GraH - Sorry I guess my explanation was not so clear as to what I wanted. Thanks sooooo much for your effort. Much appreciated.

Thanks,

M
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Thanks a trillion Peter SSs. The above formula worked. And it worked just fine. Am using the Lookup and Search option. Thanks again
You're welcome. Glad it helped. :)

For clarification in case it hasn't been obvious, the lookup/search formula returns the last matched value from the lookup table, not the last matched value in the searched text.
Example, both of these return "Air Ticket" even though "flight" and "ticket" appear in different order in A13 and A14.

20 10 04.xlsm
ABCD
1Key WordsResult
2FlightFlight
3FlightsFlight
4TicketAir Ticket
5Air TicketAir Ticket
6Air TicketsAir Ticket
7PNRPNR
8PNR'sPNR
9PNRsPNR
10
11
12DescriptionCriteriaLast Key Word
13ABC bought a flight ticket paying XXX amountAir Ticket
14ABC bought a ticket on a flightAir Ticket
Key Words
Cell Formulas
RangeFormula
D13:D14D13=LOOKUP(9.99E+307,SEARCH(" "&$A$2:$A$9&" "," "&A13&" "),$B$2:$B$9)
 
Upvote 0
Thanks Peter SSs.. Yes, I noticed that this formula captures the last matched value. Can that be changed to First Matched value instead ? Please advise.

Thanks,

M
 
Upvote 0
Can that be changed to First Matched value instead ?
Not entirely clear what you mean by first. In row 14 of my data in post 12, which result do you want?
a) Air Ticket because ticket comes before flight in cell A14, or
b) Flight because Flight comes before Ticket in the range A2:A9
 
Upvote 0
Hello Peter SSs .. i think the below examples will make this clear:

1) ABC bought a flight ticket paying XXX amount - EXPECTED RESULT - FLIGHT (NOT AIR TICKET)
2) XYZ bought 3 Air Tickets paying xxx amount - EXPECTED RESULT - AIR TICKET
3) CDE bought 1 Air Ticket vide PNR - XXXXXXX - EXPECTED RESULT - AIR TICKET (NOT PNR) \

Thanks

M
 
Upvote 0
Search any word in a text(AutoRecovered).xlsx
GHI
4DescriptionResult
5ABC bought a flight ticket paying XXX amountflight
6XYZ bought 3 Air Tickets paying xxx amountAir Ticket
7CDE bought 1 Air Ticket vide PNR - XXXXXAir Ticket
Sheet1
Cell Formulas
RangeFormula
I5:I7I5=IF(AND(IFERROR(SEARCH("pnr",G5),0)<>0,AND(IFERROR(SEARCH("pnr",G5),0)<=IF(IFERROR(SEARCH("flight",G5),0)<>0,SEARCH("flight",G5),IFERROR(SEARCH("pnr",G5),0)),IFERROR(SEARCH("pnr",G5),0)<=IF(IFERROR(SEARCH("air ticket",G5),0)<>0,SEARCH("air ticket",G5),IFERROR(SEARCH("pnr",G5),0)))),"PNR",IF(AND(IFERROR(SEARCH("flight",G5),0)<>0,AND(IFERROR(SEARCH("flight",G5),1)<=IF(IFERROR(SEARCH("pnr",G5),0)<>0,SEARCH("pnr",G5),IFERROR(SEARCH("flight",G5),0)),IFERROR(SEARCH("flight",G5),1)<=IF(IFERROR(SEARCH("air ticket",G5),0)<>0,SEARCH("air ticket",G5),IFERROR(SEARCH("flight",G5),0)))),"flight",IF(AND(IFERROR(SEARCH("air ticket",G5),0)<>0,AND(IFERROR(SEARCH("air ticket",G5),1)<=IF(IFERROR(SEARCH("pnr",G5),0)<>0,SEARCH("pnr",G5),IFERROR(SEARCH("air ticket",G5),0)),IFERROR(SEARCH("flight",G5),1)<=IF(IFERROR(SEARCH("flight",G5),0)<>0,SEARCH("flight",G5),IFERROR(SEARCH("air ticket",G5),0)))),"Air Ticket")))
 
Upvote 0
@ GraH - Sorry I guess my explanation was not so clear as to what I wanted. Thanks sooooo much for your effort. Much appreciated.

Thanks,

M
Hey, no worries. I have a patent on missunderstanding threads :). In the process learned something myself. So all is good.
 
Upvote 0
i think the below examples will make this clear:
OK, so you want option a) from my choices.

Try this.

tinferns 1.xlsm
AB
1Key WordsResult
2FlightFlight
3FlightsFlight
4TicketAir Ticket
5Air TicketAir Ticket
6Air TicketsAir Ticket
7PNRPNR
8PNR'sPNR
9PNRsPNR
10
11
12DescriptionResult
13ABC bought a flight ticket paying XXX amountFlight
14XYZ bought 3 Air Tickets paying xxx amountAir Ticket
15CDE bought 1 Air Ticket vide PNR - XXXXXXXAir Ticket
16ABC bought a ticket on a flightAir Ticket
17CDE bought 1 Air Ticket vide PNR - XXXXXXXAir Ticket
18CDE bought 1 Air voucher vide PNR on a flightPNR
Sheet1
Cell Formulas
RangeFormula
B13:B18B13=INDEX(B$2:B$9,MATCH(1,SEARCH(A$2:A$9&" ",REPLACE(A13,1,AGGREGATE(15,6,SEARCH(" "&A$2:A$9&" "," "&A13&" "),1)-1,"")&" "),0))
 
Upvote 0
Thanks Peter SSs.. that was magnificent.. Since we are on this ... I have another question and need your help on this.

Would there be a formula to extract either a Number or Number% or Date given either before or after a key word?

Key Word
Actual Sentence
Result
DiscountI got a 30% Discount on the new bed I bought30%
CostsI want to buy a car which costs Rs. 300000.00300000.00
DateI want this job to be completed by Date: 25Dec2025Dec20

Above are just examples. Actual text is similar to the above.

Await your response. .

Thanks,

M
 
Upvote 0
Could you have more then one number, a combo of number, percent and, or date in a single sentence?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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