Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Joel, thanks for taking the time to reply.
The issue is why the IsError isn't trapping the returned error value and displaying True. It's not a named range I'm using, in the example I just want the Search function to fail and the IsError to return True. When i can get this working I will search a string variable instead of "System Date". try the following : ?IsError(Application.WorksheetFunction.Search("*Va lue*Date*", "Value Date", 1)) displays False in the immediate window ?IsError(Application.WorksheetFunction.Search("Val ue Date", "System Date", 1)) gives a Run-Time error 1004 when i am expecting True. - I have taken out the wildcards and still get the same result. cheers, Paul B. -- Paul Byrne "Joel" wrote: The Wild Card * is confusing Excel. The code is looking at two strings "Value Date" and "System Date". the code below will always return a false because the string "Value Date" cannot be found inside of "System Date". I think you want variable in the string or you want the following Iserror(Application.WorksheetFunction.Search(Range ("Value Date"), Range("System Date"), 1)) The code abovewill look at the named range in your worksheet. "Dave Peterson" wrote: I see False when I do this in the immediate window. ?IsError(Application.WorksheetFunction.Search("*Va lue*Date*", "Value Date", 1)) False And this returned False: MsgBox IsError(Application.WorksheetFunction _ .Search("*Value*Date*", "Value Date", 1)) But VBA has its own version of application.search. Look at InStr() in VBA's help. Paul D Byrne wrote: Hi, I am trying to test a string in VBA to see if it exists using the following : Iserror(Application.WorksheetFunction.Search("*Val ue*Date*", "System Date", 1)) If I use the msgbox in the immediate pane to see the result I get Run-time error '1004': Unable to get the Search property of the WorksheetFunction class However using the following: Iserror(Application.WorksheetFunction.Search("*Val ue*Date*", "Value Date", 1)) evaluates to 'False' - which is what I expect. Howcome the first statement does not evaluate to True? thanks, Paul B. PS : The 2nd parameter will be a variable in production - using the words is only for development. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If IsError Help | Excel Discussion (Misc queries) | |||
=IF(ISERROR(SEARCH("insurance",A125,1)),"","*") | Excel Worksheet Functions | |||
IsError error on Search | Excel Discussion (Misc queries) | |||
IF ISERROR | Excel Discussion (Misc queries) | |||
ISERROR - #NAME? | Excel Worksheet Functions |