+ Reply to Thread
Results 1 to 6 of 6

Finding the nth occurrence after a specified position

Hybrid View

  1. #1
    Registered User
    Join Date
    07-18-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    21

    Finding the nth occurrence after a specified position

    Hello

    I am trying to find the very first occurrence of a tag "</td>" in a string after a specified position. I have attached the example spreadsheet.

    The first occurrence of the tag "</td>" is at position 40 as in the column C all the occurrences are calculated for this tag.

    However, I want to know what is the very first occurrence of the same tag "</td>" starting at position 100.

    I have tried to write this formula in cell M4 but it throws up an error unless I say the 6th occurrence instead of 1st as in cell M8 (in the actual larger spreadsheet that I am working on, I wouldn't know if its the 6th occurrence that comes after the 100th character).

    Does anyone know how to make the formula in M4 work?

    Thanks
    Regards
    Attached Files Attached Files
    Last edited by Subtle; 08-08-2017 at 09:13 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,418

    Re: Finding the nth occurrence after a specified position

    Try it this way:

    =FIND("</td>",RIGHT(A1,LEN(A1)-100))+100

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    07-18-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    21

    Re: Finding the nth occurrence after a specified position

    Thanks Pete. Your suggestion works perfectly if I want the very first instance of the tag.

    However, is there anyway I could find the subsequent instances of the same tag for example the 2nd, 3rd, 4th etc?

    Attached is the example spreadsheet where I'd like to populate the column P.


    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Finding the nth occurrence after a specified position

    Quote Originally Posted by Subtle View Post
    Thanks Pete. Your suggestion works perfectly if I want the very first instance of the tag.

    However, is there anyway I could find the subsequent instances of the same tag for example the 2nd, 3rd, 4th etc?

    Attached is the example spreadsheet where I'd like to populate the column P.


    Thanks
    p4=IFERROR(100+FIND(CHAR(1),SUBSTITUTE(RIGHT($A$1,LEN($A$1)-100),"</td>",CHAR(1),O4)),"")
    try this and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Finding the nth occurrence after a specified position

    Try=IFERROR(100+FIND(CHAR(1),SUBSTITUTE(RIGHT($A$1,LEN($A$1)-100),"</td>",CHAR(1),1)),"")
    =IFERROR(100+FIND(CHAR(1),SUBSTITUTE(RIGHT($A$1,LEN($A$1)-100),"</td>",CHAR(1),1)),"")

  6. #6
    Registered User
    Join Date
    07-18-2017
    Location
    UK
    MS-Off Ver
    2010
    Posts
    21

    Re: Finding the nth occurrence after a specified position

    Thanks nflsales. That's pretty much what I was looking for. It works perfectly.

    I have also modified Pete's formula a little bit and added in column Q which gives the same result as your formula in column R. (except I could have included IFERROR() in column Q also).
    Attached Files Attached Files

+ 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. [SOLVED] Finding last occurrence of value in row range
    By Gti182 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-19-2017, 10:28 AM
  2. [SOLVED] Finding last occurrence and summing up everything above it.
    By rdperry11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-23-2015, 05:29 AM
  3. Finding second occurrence is not working
    By allanpark in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-06-2014, 02:39 PM
  4. Finding second occurrence. HELP!
    By allanpark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2014, 09:50 PM
  5. Strings - Find position of the nth occurrence
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2009, 05:46 PM
  6. Replies: 4
    Last Post: 02-14-2006, 10:30 PM
  7. Finding Text Occurrence With C#
    By lostintheloop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2005, 01:00 AM

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