How can I test for a string in an activeworkbooks name?
I tried this:
[VBA]If activeworkbook.name = "*est*" then[/VBA]
I though a wildcard character would work but it didn't.
How can I test for a string in an activeworkbooks name?
I tried this:
[VBA]If activeworkbook.name = "*est*" then[/VBA]
I though a wildcard character would work but it didn't.
Daniel,
Replace the "=" sign with LIKE. Here is what Help has to say:
"Like Operator Example (Microsoft Excel)
This example deletes every defined name that contains "temp". The Option Compare Text statement must be included at the top of any module that contains this example.
For Each nm In ActiveWorkbook.Names
If nm.Name Like "*temp*" Then
nm.Delete
End If
Next nm"
Cheers,
Ron
Windermere, FL
Thank you that worked perfectly. so whenever I want to use a wild character I need to use like?
Yes, if you are searching for the existence of a substring within a test string.
Cheers,
Ron
Windermere, FL
You can also use InStr
[vba]
If InStr(nm.Name, "temp") > 0 Then
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber