SEARCH() in a macro


Posted by C Toland on May 16, 2001 3:44 AM

SEARCH is not working in a macro - vba kicks it out saying not a function,,it does work on a regular spreadsheet,, is there a workaround or another solution if putting within a macro


=ISNUMBER(SEARCH("*omr*","omr-real"))+0

need:
if ("omr" IN "omr-test") then ...

Posted by Sean on May 16, 2001 4:51 AM

========
Hi,

Try building the following into your Macro

Sub lookitup()

LookFor = "the"
LookIn = "When the moon"
Found = InStr(1, LookIn, LookFor, vbTextCompare)
If Found > 0 Then '
MsgBox "I found it in Position " & Found
End If

End Sub


This gives you all the required elements, including the if test

Sean



Posted by Dave Hawley on May 16, 2001 5:08 AM


Hi C Toland

You could use the Like function for this:

Option Compare Text
Sub TryThis()
Dim sT1 As String
Dim sT2 As String

sT1 = "omr-real"
sT2 = "omr*"

If sT1 Like (sT2) Then
MsgBox 1
Else
MsgBox 0
End If

End Sub

The "Option Compare Text" will make A=a
Use "Option Compare Binary" for A<>a<p>
Dave
OzGrid Business Applications