Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 30
Default How to find SECOND occurrence in a string?

I need a formula to find the position of the SECOND occurrence of a character
in a string. I can find the first occurrence using the FIND function no
problem but I have no idea how to find the position of the second occurrence
formulaically. Is there a formula to do that without running VBA?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How to find SECOND occurrence in a string?

Try this:

A1 = abcdabc

Find position of 2nd "a":

=FIND("a",A1,FIND("a",A1)+1)

Result = 5

Note that FIND is case sensitive. If you want to exclude case sensitivity
replace FIND with SEARCH.

Biff

"Bill_S" wrote in message
...
I need a formula to find the position of the SECOND occurrence of a
character
in a string. I can find the first occurrence using the FIND function no
problem but I have no idea how to find the position of the second
occurrence
formulaically. Is there a formula to do that without running VBA?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 29
Default How to find SECOND occurrence in a string?

Say you have the word "supercalifragilistic" in Cell C6.
To find the second occurrence of the letter "a", you could use the
formula:
= FIND("a",C6,1) + FIND("a",MID(C6,FIND("a",C6,1)+1,LEN(C6)),1)
which will return the value of '12'. Others may have a simpler
formulas, however.

/ Tyla /



On Mar 19, 10:08 am, Bill_S wrote:
I need a formula to find the position of the SECOND occurrence of a character
in a string. I can find the first occurrence using the FIND function no
problem but I have no idea how to find the position of the second occurrence
formulaically. Is there a formula to do that without running VBA?



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 30
Default How to find SECOND occurrence in a string?

Wow, beautiful solution, and so simple. I am often surprised at how some of
the best Excel solutions are the shortest. Thanks!


"T. Valko" wrote:

Try this:

A1 = abcdabc

Find position of 2nd "a":

=FIND("a",A1,FIND("a",A1)+1)

Result = 5

Note that FIND is case sensitive. If you want to exclude case sensitivity
replace FIND with SEARCH.

Biff

"Bill_S" wrote in message
...
I need a formula to find the position of the SECOND occurrence of a
character
in a string. I can find the first occurrence using the FIND function no
problem but I have no idea how to find the position of the second
occurrence
formulaically. Is there a formula to do that without running VBA?




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How to find SECOND occurrence in a string?

You're welcome. Thanks for the feedback!

Biff

"Bill_S" wrote in message
...
Wow, beautiful solution, and so simple. I am often surprised at how some
of
the best Excel solutions are the shortest. Thanks!


"T. Valko" wrote:

Try this:

A1 = abcdabc

Find position of 2nd "a":

=FIND("a",A1,FIND("a",A1)+1)

Result = 5

Note that FIND is case sensitive. If you want to exclude case sensitivity
replace FIND with SEARCH.

Biff

"Bill_S" wrote in message
...
I need a formula to find the position of the SECOND occurrence of a
character
in a string. I can find the first occurrence using the FIND function no
problem but I have no idea how to find the position of the second
occurrence
formulaically. Is there a formula to do that without running VBA?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Most common occurrence of a string Mike Archer Excel Worksheet Functions 1 February 23rd 07 12:05 AM
Index function to find nth occurrence Ken Excel Worksheet Functions 4 November 15th 06 06:35 PM
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
Find nth occurrence and replace with ":" marlea Excel Worksheet Functions 4 October 5th 05 10:43 PM
find last occurrence REMnLYN Excel Worksheet Functions 9 March 29th 05 10:43 AM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"