Search array for string

N

navin

Hi all,

Is there a function in vba to search occurrence of a letter and return
its index?
I need to find the first and nth index of a character in an array.

Array: (****+++++++**)

I need to find out the first occurrence of + and last occurrence of +
in the array. I got the result by looping thru the array but was
hoping
to find out a smaller function to achieve this.

Thanks for the help.

Navin
 
M

Matt Richardson

Hi all,

Is there a function in vba to search occurrence of a letter and return
its index?
I need to find the first and nth index of a character in an array.

Array: (****+++++++**)

I need to find out the first occurrence of + and last occurrence of +
in the array. I got the result by looping thru the array but was
hoping
to find out a smaller function to achieve this.

Thanks for the help.

Navin

I've created an excel add-in that has a couple of functions in it that
might help with what you're after:-

http://2toria.com/downloads/

HTH
Matt
http://2toria.com
http://teachr.blogspot.com
 
N

navin

I've created an excel add-in that has a couple of functions in it that
might help with what you're after:-

http://2toria.com/downloads/

HTH
Matthttp://2toria.comhttp://teachr.blogspot.com


Hi,

thanks for the reply. I actually wrote a function to find out the
result
but hoping to find some built in function to do this search and get
the index. Somehing like instr.
 
D

Dave Peterson

If you're really looking through a string -- not an array, you could use VBA's
Instr to find the first position.

And if you're using xl2k or higher, you could use RevInStr to find the last
position.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top