+ Reply to Thread
Results 1 to 7 of 7

Position for the 3rd and 4th appearance of a character in a text string

  1. #1
    Registered User
    Join Date
    05-15-2004
    Posts
    13

    Position for the 3rd and 4th appearance of a character in a text string

    Hi,
    I’m looking for an Excel function (not a VBA) which returns the position of the 3rd and 4th time a specific character appears in a text string – for example @

    Example text string in cell A1:
    what@time@is@it@right@now

    In the text string above – the position of the 3rd and 4th time the @ is displayed is position 13 and position 16

    I have tried to use the =FIND() function – but the problem is that I then have to refer back to the 'previous' cell to find the ‘start_num’ and I would like to have the columns independent of each other.

    Thanks,
    Sven

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Position for the 3rd and 4th appearance of a character in a text string

    =FIND("^",SUBSTITUTE(A1,"@","^",3)) and =FIND("^",SUBSTITUTE(A1,"@","^",4))
    if you use ^ somewhere pick a character you aren't likely to have
    say
    =FIND("~",SUBSTITUTE(A1,"@","~",3))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    05-15-2004
    Posts
    13

    Re: Position for the 3rd and 4th appearance of a character in a text string

    Hi martindwilson,
    I tried to have cell
    A1 => what@time@is@it@right@now
    B1 => FIND("^",SUBSTITUTE(A1,"@","^",3))

    Sorry if I ask a stupid question - but I don't understand what to put in instead of "^" in your solution in cell B1? I would like to display 13 in cell B1 because that is the position when the character @ is displayed the 3rd time in the text string - and i don't understand how to achieve that?

    Thanks for clarifying,
    Sven

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Position for the 3rd and 4th appearance of a character in a text string

    Just use that formula exactly......

    =FIND("^",SUBSTITUTE(A1,"@","^",3))
    Audere est facere

  5. #5
    Registered User
    Join Date
    05-15-2004
    Posts
    13

    Re: Position for the 3rd and 4th appearance of a character in a text string

    Great! – it now works.

    The problem was that in my regional setting I use ; instead of ,

    =FIND("^",SUBSTITUTE(A1,"@","^",3))
    =FIND("^";SUBSTITUTE(A1;"@";"^";3)) (this works for me)

    Last question about the character ^ you have in your example:
    Question: Is it true that you need to set something that you know for sure you will never have in the text string? (for example ^ )

    Thanks,
    Sven

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Position for the 3rd and 4th appearance of a character in a text string

    true. You can use some CHAR(155) or something less likely

  7. #7
    Registered User
    Join Date
    05-15-2004
    Posts
    13

    Re: Position for the 3rd and 4th appearance of a character in a text string

    OK - thanks ALL.
    Case SOLVED :-)

+ 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