using instr function

ashley789

New Member
Joined
Jun 21, 2002
Messages
17
hello

is it possible to use instr function to
locate the next character
for ex within string ( ab_ _ cd_ _ _ e)
instr (1, string, "char")
i would like the function to return
5 for "c" and 9 for "e"

any advice would be much appreciated .
irene
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
On 2002-09-09 15:11, ashley789 wrote:
hello

is it possible to use instr function to
locate the next character
for ex within string ( ab_ _ cd_ _ _ e)
instr (1, string, "char")
i would like the function to return
5 for "c" and 9 for "e"

any advice would be much appreciated .
irene

I'm not sure I get what you are saying. Can you expand on your example? Maybe even give us a working example from your data: what you have, and what you want to end up with.

Using InStr will give you these numbers:

NumberForE = InStr("abcdefghij","e")
NumberForJ = InStr("abcdefghij","j")

NumberForE will be 5 and NumberForJ will be 10. Not sure if that's what you wanted (I doubt it), but I thought I'd throw it out there anyway. The [Start] argument to InStr is Optional, and if you omit it, it starts at one.

-Russell
 
Upvote 0
russell,
i would like to avoid hardcoding the instr function with a certain character.Since I do not know what the next character might be, I would like the search to be flexible . I was wondering if there is a way to define the arguments within the instr to locate the next first character of the word.
i hope this provides a little more clarity.

ashley

On 2002-09-09 15:42, Russell Hauf wrote:
On 2002-09-09 15:11, ashley789 wrote:
hello

is it possible to use instr function to
locate the next character
for ex within string ( ab_ _ cd_ _ _ e)
instr (1, string, "char")
i would like the function to return
5 for "c" and 9 for "e"

any advice would be much appreciated .
irene

I'm not sure I get what you are saying. Can you expand on your example? Maybe even give us a working example from your data: what you have, and what you want to end up with.

Using InStr will give you these numbers:

NumberForE = InStr("abcdefghij","e")
NumberForJ = InStr("abcdefghij","j")

NumberForE will be 5 and NumberForJ will be 10. Not sure if that's what you wanted (I doubt it), but I thought I'd throw it out there anyway. The [Start] argument to InStr is Optional, and if you omit it, it starts at one.

-Russell
 
Upvote 0
i hope this provides a little more clarity.

Not really. Again, a real example of what you want to do would be of great help. You can pass a variable to the InStr function, but we need to know what you want to do in order to help you do that...
This message was edited by Russell Hauf on 2002-09-10 08:46
 
Upvote 0

Forum statistics

Threads
1,222,072
Messages
6,163,751
Members
451,855
Latest member
mcook36155

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top