Instr question

S

Sandy H

Hi
Can anyone tell me whether it is possible to apply more than one search
character to the Instr function. To give an example of what I mean, I want
to find either an 'A' or a '2'. Can this be done in the one instr
statement.

Thanks
Sandy
 
S

stefan hoffmann

hi Sandy,

Sandy said:
Can anyone tell me whether it is possible to apply more than one search
character to the Instr function. To give an example of what I mean, I want
to find either an 'A' or a '2'. Can this be done in the one instr
statement.
No, but maybe is the Microsoft RegEx library of interest for you. You
can activate it in the VBA references dialog.


mfG
--> stefan <--
 
S

stefan hoffmann

hi,
No, but maybe is the Microsoft RegEx library of interest for you. You
can activate it in the VBA references dialog.
It is called "Microsoft VBScript Regular Expressions".


mfG
--> stefan <--
 
J

John Nurick

Hi Sandy,

If you just want to know whether a string _contains_ the characters in
question, you can use the Like operator, e.g.

S = "Once upon a time"
? S Like "*[A2]*"
True

If you need to know the _position_ of the character(s) in the string, or
if you're searching for something more complicated than one of a number
of characters (e.g. an "A2" or a "B4"), the obvious ways are to use
either one call to InStr() for each character or a regular expression
engine.

There's some information about using regular expressions in VBA, and a
couple of useful functions, at
http://www.j.nurick.dial.pipex.com/Code/index.htm
 
S

Sandy H

Thanks Stefan and John. I thought that was the case.

Appreciate your help.

Sandy
John Nurick said:
Hi Sandy,

If you just want to know whether a string _contains_ the characters in
question, you can use the Like operator, e.g.

S = "Once upon a time"
? S Like "*[A2]*"
True

If you need to know the _position_ of the character(s) in the string, or
if you're searching for something more complicated than one of a number
of characters (e.g. an "A2" or a "B4"), the obvious ways are to use
either one call to InStr() for each character or a regular expression
engine.

There's some information about using regular expressions in VBA, and a
couple of useful functions, at
http://www.j.nurick.dial.pipex.com/Code/index.htm

Hi
Can anyone tell me whether it is possible to apply more than one search
character to the Instr function. To give an example of what I mean, I
want
to find either an 'A' or a '2'. Can this be done in the one instr
statement.

Thanks
Sandy
 
Top