+ Reply to Thread
Results 1 to 5 of 5

Find last occurence

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    811

    Find last occurence

    =find("a",F3,3) will find where the letter 'a' occurs for the third time in cell F3 but how do you find the last place 'a' occurs in cell F3?
    Last edited by BRISBANEBOB; 02-23-2010 at 09:55 PM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Find last occurance

    How about this

    =SEARCH("^^",SUBSTITUTE(F3,"a","^^",LEN(F3)-LEN(SUBSTITUTE(F3,"a",""))))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    811

    Re: Find last occurence

    OK, that is seriously spooky. It works beautifully, but how?

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Find last occurence

    LEN(F3)-LEN(SUBSTITUTE(F3,"a","")) counts the number of "a"

    SUBSTITUTE(F3,"a","^^"...... substitutes the nth occurrence of "a" (the occurrence is determined above)

    =Search("^^".....finds where the last a was.

  5. #5
    Forum Contributor
    Join Date
    12-02-2008
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    811

    Re: Find last occurence

    Amazing - thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1