Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I find the cell address of the 2nd largest of a set? | Excel Discussion (Misc queries) | |||
find a cells from a range of cell | Excel Worksheet Functions | |||
Using the Find tool in EXCEL | Excel Worksheet Functions | |||
Excel has a "Find Next" command but no "Find Previous" command. | Excel Discussion (Misc queries) | |||
boolean find criteria in Excel | Excel Discussion (Misc queries) |