+ Reply to Thread
Results 1 to 7 of 7

Count from the right in a string.

  1. #1
    Registered User
    Join Date
    12-27-2006
    Location
    Australia
    MS-Off Ver
    Microsoft 365
    Posts
    87

    Count from the right in a string.

    Hi,

    I have a string of numbers representing a horse's last 10 races as below.

    s04781s249

    I am trying to count the runs since the last spell represented by "s". The formula I have =IFERROR(LEN(T2)-FIND("s",T2,1),"") only works if there is one "s". In ths case above in will give the result 9.

    I would like a fomula that counts from the right to give the result as above "3".

    Any help would be appreciated.

    Bob

  2. #2
    Registered User
    Join Date
    12-27-2006
    Location
    Australia
    MS-Off Ver
    Microsoft 365
    Posts
    87

    Re: Count from the right in a string.

    Sample of the worksheet attached.
    Attached Files Attached Files

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Count from the right in a string.

    Please try

    =LEN(-LOOKUP(0,-RIGHT(T2,SEQUENCE(LEN(T2)))))

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Count from the right in a string.

    Maybe this:

    =LEN(TRIM(TRIM(RIGHT(SUBSTITUTE(A1,"s",REPT(" ",100)),100))))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    12-27-2006
    Location
    Australia
    MS-Off Ver
    Microsoft 365
    Posts
    87

    Re: Count from the right in a string.

    That does the trick Glen. You are a champion. Thank you.

  6. #6
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Count from the right in a string.

    Quote Originally Posted by Bob1955 View Post
    You are a champion.
    but why
    Please Login or Register  to view this content.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Count from the right in a string.

    Absolutely no idea why.... seeing double??

    =LEN(TRIM(RIGHT(SUBSTITUTE(D7,"s",REPT(" ",100)),100)))

    ...unless it's because I'm Irish... to be sure to be sure....

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Text String Count
    By Mikeyabosbht in forum Excel General
    Replies: 5
    Last Post: 07-23-2017, 04:39 PM
  2. Replies: 5
    Last Post: 12-14-2014, 10:59 PM
  3. Replies: 9
    Last Post: 10-17-2011, 04:33 PM
  4. count number of instances of string in a string
    By lawrencef in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-28-2008, 02:06 AM
  5. count commas within a string
    By excelsteve in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-13-2007, 08:16 AM
  6. Count Cells That Do'nt Contain A Specified String
    By OzTrekker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2007, 12:08 AM
  7. [SOLVED] count in a string
    By SHIRA in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2006, 03:10 PM

Tags for this Thread

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