#1   Report Post  
Bill
 
Posts: n/a
Default Boolean Find

Hello,

I think I've seen a post here explaining a way to use the Find Method in VBA
to effectively return "True" or "False". I have a variable string that I
want to search for a particular sub-string. If it contains Sub-String A, I
perform Action A, if it is Sub-String B, I perform Action B, and if it is
neither, I perform Action C.

Any suggestions?

Bill


  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Do you mean in a formula?

=IF(ISNUMBER(FIND("substringA","string")),"Action
A",IF(ISNUMBER(FIND("substringB","string")),"Actio n B","Action C"))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bill" wrote in message
...
Hello,

I think I've seen a post here explaining a way to use the Find Method in

VBA
to effectively return "True" or "False". I have a variable string that I
want to search for a particular sub-string. If it contains Sub-String A,

I
perform Action A, if it is Sub-String B, I perform Action B, and if it is
neither, I perform Action C.

Any suggestions?

Bill




  #3   Report Post  
Bill
 
Posts: n/a
Default

Sorry, no, I meant in a macro.

Anyway, I used "Like" as follows:

Dim mysearchresult as Boolean
mysearchresult = False
mysearchresult = mySubjectText Like mySearchTextA
If mysearchresult then
Action A
Else
mysearchresult = mySubjectText Like mySearchTextB
If mysearchresult then
Action B
Else
Action C
End if
End if

Note that I have a variable, mySearchTextA. You specify the search text
explicitly using double-quotes. In any case, you can use typical
wildcareds, such as an asterisk for "any number of any character".

Thanks for the reply.

"Bob Phillips" wrote in message
...
Do you mean in a formula?

=IF(ISNUMBER(FIND("substringA","string")),"Action
A",IF(ISNUMBER(FIND("substringB","string")),"Actio n B","Action C"))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bill" wrote in message
...
Hello,

I think I've seen a post here explaining a way to use the Find Method in

VBA
to effectively return "True" or "False". I have a variable string that I
want to search for a particular sub-string. If it contains Sub-String A,

I
perform Action A, if it is Sub-String B, I perform Action B, and if it is
neither, I perform Action C.

Any suggestions?

Bill






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 do I find the cell address of the 2nd largest of a set? Mr. Snrub Excel Discussion (Misc queries) 4 May 30th 05 12:53 PM
find a cells from a range of cell kelvintaycc Excel Worksheet Functions 2 April 2nd 05 07:20 PM
Using the Find tool in EXCEL TK Excel Worksheet Functions 2 February 11th 05 07:51 PM
Excel has a "Find Next" command but no "Find Previous" command. Michael Fitzpatrick Excel Discussion (Misc queries) 2 January 10th 05 11:45 PM
boolean find criteria in Excel davista00 Excel Discussion (Misc queries) 1 December 1st 04 03:45 PM


All times are GMT +1. The time now is 11:41 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"