ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If CONTAINS (https://www.excelbanter.com/excel-discussion-misc-queries/39708-if-contains.html)

Kel

If CONTAINS
 
Hi all!!!

Im trying to figure how in a "IF formula" you do the following,
Also i would like to have it for VB.
Thanx

IF(A1 CONTAINS (beetween other words) jump,TRUE,FALSE

say A1 contains text like this "i like to jump to the roof" or "to the roof
i lilke to jump" not in a particular position, return cell B1 to say "NO"

Thank you all.

Dave O

The syntax is
=IF(SEARCH("jump",A1,1)0,TRUE,FALSE)

In VBA the code is
If InStr(1, Range("a1").Value, "jump") 0 Then


Ron Rosenfeld

On Wed, 10 Aug 2005 10:46:08 -0700, Kel wrote:

Hi all!!!

Im trying to figure how in a "IF formula" you do the following,
Also i would like to have it for VB.
Thanx

IF(A1 CONTAINS (beetween other words) jump,TRUE,FALSE

say A1 contains text like this "i like to jump to the roof" or "to the roof
i lilke to jump" not in a particular position, return cell B1 to say "NO"

Thank you all.


In Excel, you would use the FIND or SEARCH worksheet functions and, if the
#Value! error is returned, then the search string was not found.

In VBA you would use the InStr Function


--ron

Dave Peterson

=if(isnumber(search("jump",a1)),true,false)

or even:
=isnumber(search("jump",a1))


Kel wrote:

Hi all!!!

Im trying to figure how in a "IF formula" you do the following,
Also i would like to have it for VB.
Thanx

IF(A1 CONTAINS (beetween other words) jump,TRUE,FALSE

say A1 contains text like this "i like to jump to the roof" or "to the roof
i lilke to jump" not in a particular position, return cell B1 to say "NO"

Thank you all.


--

Dave Peterson


All times are GMT +1. The time now is 10:45 AM.

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