# using instr function

#### ashley789

##### New Member
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 total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

#### Russell Hauf

##### MrExcel MVP
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

#### ashley789

##### New Member
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

#### Juan Pablo González

##### MrExcel MVP
Ashley, are you trying to find where eac word begins ?

#### Russell Hauf

##### MrExcel MVP
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

Replies
2
Views
350
Replies
1
Views
726
Replies
7
Views
1K
Replies
1
Views
338
Replies
1
Views
603

1,182,137
Messages
5,933,854
Members
436,915
Latest member
Cygne volant

### 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.

### Which adblocker are you using?

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

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