ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If a cell contains "preferred" then do this (https://www.excelbanter.com/excel-discussion-misc-queries/110216-if-cell-contains-preferred-then-do.html)

stevec

If a cell contains "preferred" then do this
 
here is what I got =if(a1="*preferred*","B","A")

what do I do to make it work?

thanks... Steve

trying to match partial text in a cell

a1 might have "preferred chimichangas" or "preferred nonsense" for example...

Dave Peterson

If a cell contains "preferred" then do this
 
One way:

=if(countif(a1,"*preferred*")0,"B","A")

another:
=if(isnumber(search("preferred",a1)),"B","A")

if you want to make it case sensitive, replace "search" with "find".

(=Countif() is not case sensitive)

SteveC wrote:

here is what I got =if(a1="*preferred*","B","A")

what do I do to make it work?

thanks... Steve

trying to match partial text in a cell

a1 might have "preferred chimichangas" or "preferred nonsense" for example...


--

Dave Peterson

stevec

If a cell contains "preferred" then do this
 
great. thanks!


Tracey

If a cell contains "preferred" then do this
 
Thank you Dave,

You saved me hours of work!!!!!
I needed the same formula as well!!!



"Dave Peterson" wrote:

One way:

=if(countif(a1,"*preferred*")0,"B","A")

another:
=if(isnumber(search("preferred",a1)),"B","A")

if you want to make it case sensitive, replace "search" with "find".

(=Countif() is not case sensitive)

SteveC wrote:

here is what I got =if(a1="*preferred*","B","A")

what do I do to make it work?

thanks... Steve

trying to match partial text in a cell

a1 might have "preferred chimichangas" or "preferred nonsense" for example...


--

Dave Peterson



All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com