Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Josh Craig
 
Posts: n/a
Default Can I create an IF statement that looks for part of a string of te

I want to create a condition for an IF() formula based on part of the text in
an adjacent cell.

For example:

So if B1 contains the phrase "version 1" return one value and return another
if it doesn't have it.

But I don't mean B1 is exactly equal to "version 1" but rather that it
contains "version 1" someone in the text of that cell. Is there some way I
can accomplish this?

Effectively I want it to be able to test if B1=*"version 1" where * equals a
wildcard like on a search engine.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max
 
Posts: n/a
Default Can I create an IF statement that looks for part of a string of te

One way ..

Try in say, C1, something like:
=IF(ISNUMBER(SEARCH("version 1 ",TRIM(B1))),"Y","N")

Replace "Yes", "No", with whatever you want as the if_TRUE/if_FALSE returns

Note that the single space after the "1" in the search string: "version 1 "
is intentional, so that it doesn't evaluate as TRUE for strings such as:
version 123, version 111, etc. But if you want it otherwise, just remove the
single space.

Replace SEARCH with FIND in the formula if you need it to be case sensitive
(SEARCH is not case sensitive)
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Josh Craig" wrote:
I want to create a condition for an IF() formula based on part of the text in
an adjacent cell.

For example:

So if B1 contains the phrase "version 1" return one value and return another
if it doesn't have it.

But I don't mean B1 is exactly equal to "version 1" but rather that it
contains "version 1" someone in the text of that cell. Is there some way I
can accomplish this?

Effectively I want it to be able to test if B1=*"version 1" where * equals a
wildcard like on a search engine.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Peter from Novartis
 
Posts: n/a
Default Can I create an IF statement that looks for part of a string of te

John, Try "=IF(FIND("version 1";B1;1)"Yes";"No")"
The "1" behind the B1 reference relates to the search start position. The
only problem here is that if the expression is not found, you get an
"#Value!" result. If you are not happy with the error message (like if you
need to use the result in another calculation), you can start from the other
side - try using something like this: =IF(ISERROR(FIND("version
1";B1;1));"No";"Yes") where you first make sure that if the error message
appears, it is an expected result that will have the "No" as an answer.
Josh Craig pÃ*Å¡e:

I want to create a condition for an IF() formula based on part of the text in
an adjacent cell.

For example:

So if B1 contains the phrase "version 1" return one value and return another
if it doesn't have it.

But I don't mean B1 is exactly equal to "version 1" but rather that it
contains "version 1" someone in the text of that cell. Is there some way I
can accomplish this?

Effectively I want it to be able to test if B1=*"version 1" where * equals a
wildcard like on a search engine.

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
How to pass a variable into an SQL statement CLamar Excel Discussion (Misc queries) 0 June 5th 06 02:17 PM
LOOKUP a text string created from IF statement Steve-in-austin Excel Discussion (Misc queries) 0 May 11th 06 09:10 PM
CREATE AN "IF' STATEMENT FOR CHOICES OF CHECK BOXES pjb Excel Worksheet Functions 7 May 8th 06 08:57 PM
If statement Matt Montagliano Excel Discussion (Misc queries) 1 September 8th 05 08:47 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 08:19 PM.

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

About Us

"It's about Microsoft Excel"