Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default if statements using contains

I have a string of data in a cell and I want to say
If(a2 contains "admin","true,"false")
I don't know how to say "contains" in this format, I may want to expand of
the logic and say if(a2 contains "admin" and (contains
"conversion"),1.25,false))

Cell a2 contains; plant one administrative assit(conversion)
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default if statements using contains

Hi,

=NOT(ISERROR(SEARCH("Admin",A2)))

and this

IF(NOT(ISERROR(AND(SEARCH("Admin",A2),SEARCH("Conv ersion",A2)))),1.25,"False")

Mike

Mike

"Merge" wrote:

I have a string of data in a cell and I want to say
If(a2 contains "admin","true,"false")
I don't know how to say "contains" in this format, I may want to expand of
the logic and say if(a2 contains "admin" and (contains
"conversion"),1.25,false))

Cell a2 contains; plant one administrative assit(conversion)

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default if statements using contains

Q1: =IF(ISNUMBER(FIND("admin",A1)),TRUE,FALSE)
Note I am using Boolean values TRUE/FALSE but you could use text
=IF(ISNUMBER(FIND("admin",A1)),"True", "False")
But we do not need IF when only TRUE/FALSE is required,
we can use just =ISNUMBER(FIND("admin",A1))

Q2:
=IF(AND(ISNUMBER(FIND("admin",A1)),ISNUMBER(FIND(" conversion",A1))),1.25,FALSE)
but again we can simplify with
=IF(AND(ISNUMBER(FIND("admin",A1)),ISNUMBER(FIND(" conversion",A1))),1.25)
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Merge" wrote in message
...
I have a string of data in a cell and I want to say
If(a2 contains "admin","true,"false")
I don't know how to say "contains" in this format, I may want to expand of
the logic and say if(a2 contains "admin" and (contains
"conversion"),1.25,false))

Cell a2 contains; plant one administrative assit(conversion)



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 171
Default if statements using contains

=IF(ISNUMBER(FIND("admin",A2)),TRUE,FALSE)
(If you really only need the true or false result, you could skip the IF and
just use =ISNUMBER(FIND("admin",a2)); the result of the ISNUMBER function
will be either TRUE or FALSE, making the IF redundant.)

To require two strings to match within a single cell:
=IF(AND(ISNUMBER(FIND(string1,a2)),ISNUMBER(FIND(s tring2,a2))),true_value,false_value)

Be aware that the FIND is case-sensitive. You could get around that by
using UPPER to convert the input and comparing to an uppercase string:
=ISNUMBER(FIND("ADMIN",UPPER(a2))



"Merge" wrote:

I have a string of data in a cell and I want to say
If(a2 contains "admin","true,"false")
I don't know how to say "contains" in this format, I may want to expand of
the logic and say if(a2 contains "admin" and (contains
"conversion"),1.25,false))

Cell a2 contains; plant one administrative assit(conversion)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statements (Mutliple Statements) Deezel Excel Worksheet Functions 3 October 19th 06 06:13 AM
If statements fuzzylogic Excel Worksheet Functions 9 September 19th 06 02:07 AM
IF Statements Julie Excel Discussion (Misc queries) 1 May 1st 06 07:45 PM
IF statements y_not Excel Discussion (Misc queries) 4 August 9th 05 04:35 PM
IF statements cb3291u Excel Discussion (Misc queries) 1 August 5th 05 03:42 PM


All times are GMT +1. The time now is 06:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"