Searching for two text terms in a cell to return a value

Balmer07

New Member
Joined
Feb 14, 2018
Messages
45
Office Version
  1. 365
Hi,

In cell A1 I have detail like below:
"Sale - I will give a towel"

What I need is for an if formula to look for both terms "Sale" and Towel" in the cell, if both terms are there I need it to return "Sale1" If only "Sale" is in the cell I need it to return "Sale2"

I hope this makes sense, ask if you need further detail

thanks,
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Perhaps =IF(AND(SUMPRODUCT(--ISNUMBER(FIND("towel",A1))),SUMPRODUCT(--ISNUMBER(FIND("Sale",A1)))),"Sale1",IF(SUMPRODUCT(--ISNUMBER(FIND("Sale",A1))),"Sale2",0))

(can be shortened if one of both strings is always present)
 
Upvote 0
I think this formula will also do what you want...

=IF(COUNTIFS(A1,"*sale*",A1,"*towel*"),"Sale1",IF(COUNTIF(A1,"*sale*"),"Sale2",""))
 
Upvote 0
Hi,

Just another way:


Book1
AB
1Sale - I will give a towelSale1
2I will give a towel
3Sale - I will give a robeSale2
Sheet316
Cell Formulas
RangeFormula
B1=IF(COUNTIF(A1,"*Sale*"),IF(COUNTIF(A1,"*Towel*"),"Sale1","Sale2"),"")
 
Upvote 0

Forum statistics

Threads
1,215,148
Messages
6,123,307
Members
449,095
Latest member
Chestertim

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