+ Reply to Thread
Results 1 to 8 of 8

Finding every occurance of a string

  1. #1
    Registered User
    Join Date
    01-09-2015
    Location
    Reseda, CA
    MS-Off Ver
    MSOffice 365
    Posts
    23

    Finding every occurance of a string

    We are doing DNA research. We need to find all starting positions of a discreet string of characters within a larger string of characters. Below is a sample source string. Using FIND, we note that the first instance of TATAA from the left is at character 286. I think we can use the AGGREGATE formula (15 Small and 6 Ignore hidden values) to present all instances but I can't make it work. The ideal result would actually display the results from the right end of the source string. A result might be 6, 50, 75 (though that is not the case below). It doesn't matter if the list of occurences is presented in a column or row.

    If you find a great answer, then you will be helping figure out one of the great mysteries of life.

    Sample string (in cell B9)
    GGGAGTGTTATTTTAATAAAATTGCTAGTTATTGTTGTAACGCATTCGTCTTATTCGAATCAAAACGACAATTTCTTCCTACTCAGTGTACATACATGAAAAAAATAACTGTTTAATACACGAAGGAAACACATTAACAATTCTGTTGCGAAAAATATAGCGTTGTAAATTTTGACATACGCTTATTTTTTAAAATAAGAAAGACGATTTCTCTATTTTTCTTGATATTTATCCTTCCGCAATTGTCGTGACAATTTGTTCTCTCCTCTTCTTCAAGGCAACGATTATAACACAGTTATTTGAATATCACTCAAGTGTAACGGTTTCGAGCTCTTCGATATTTTCACGTAGCACGCGCCTGTGATGTTCTAGTTCTTAGAAAAACATATAATAACGGAAAAACGTCTCACCTTTCGTTGTTCCGTTTTTCTGAATCTGTACTCGACACCCTGTACACCTTCATTACTTTCAATGCAATTCGGTTGTTCATACCAATATCACATTTCATATGGACTCTTATATGTCAACGATTTAGCGTAAAAGCATTATTCACTGCACTTCTGATGACGATGCGCGAATTAAATCTATAACAAACGTTGCATCAAAAACGTTGAGTTAAACAAAATATCGCGCAATTGAGACATAAACAAAAAAAAAACGAGATATTTTTGTCCATTTATTACGAAAGTAACTCGCGATGTTCTTCCGTCATTTGTAAGACAAGACATGTAATAATTTTTCTCTTACTGTTCGTGTGCGATATGAGCGCAACTGTGGAGTTAGATAGGTAGCGATGTACAAAACGTAACCATATAGTTTCTTGGTCAGAACAATTTGACACAATAGAGCACTTCTCCGCATTTTGCACTAATGCGTGCGTAAAGACGGGTTGACAAGCGGGTATACGTCCCGAGCTGAATAAAAAATAGATCCTGATACTTGCGTCGCGTCGACGTAGCGAGAGCGGGATCGGTTATTGACGACAGCTAGTAGTTAGTCA
    Last edited by WilliamWelch; 06-12-2019 at 07:35 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Finding every occurance of a string

    Hi William,

    See the attached with this formula to do what you request:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Put any DNA string in B4 and longer string in B6 and the formula should work. There might be a limit for the length of the string in B6.

    DNA Strings Location.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding every occurance of a string

    This returns a different value.

    Using search string from post 1 TATAA in B4 and with the target string in B9. Returns 3.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  4. #4
    Registered User
    Join Date
    01-09-2015
    Location
    Reseda, CA
    MS-Off Ver
    MSOffice 365
    Posts
    23

    Re: Finding every occurance of a string

    Thank you. Those tell me the number of instances. What I'm looking for is the position with in the string. For example:

    abcabcabc

    If searching for "c", the result would be positions 3,6, and 9 from the left side or 1,4,7 from the right side (preferred).

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Finding every occurance of a string

    How about
    Please Login or Register  to view this content.
    used like
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Finding every occurance of a string

    Attached is a Power Query solution for those using Excel 2010 or newer.

    I used this tutorial to incorporate the search letter into the query.

    All that you have to do once this is created is change the value in the Search Letter cell and refresh the green table.
    Attached Files Attached Files
    Last edited by 63falcondude; 06-13-2019 at 02:41 PM.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding every occurance of a string

    Quote Originally Posted by WilliamWelch View Post
    Thank you. Those tell me the number of instances. What I'm looking for is the position with in the string. For example:

    abcabcabc

    If searching for "c", the result would be positions 3,6, and 9 from the left side or 1,4,7 from the right side (preferred).
    My apologies. I read it wrong.

    If you are still interested in a formula solution in the attached please find one requiring a helper row. BTW the DNA string had an extra space. It is removed in the attached.

    In B5 filled across returns the positions --- left to right.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In B6 filled across references the above returns positions right to left.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by FlameRetired; 06-13-2019 at 06:48 PM.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding every occurance of a string

    Here's another. No helpers. Since you mentioned AGGREGATE I used it.

    BTW: Please update your profile. AGGREGATE is a newer function (2010).
    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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 Max Occurance Based on Criteria
    By Butcher1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-26-2014, 08:07 AM
  2. Finding last occurance in a row range
    By JoshExcel in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-12-2013, 09:24 PM
  3. Finding the last occurance of a value in a matrix
    By Ayjay in forum Excel General
    Replies: 1
    Last Post: 07-15-2011, 02:27 AM
  4. Finding the Nth Occurance in a Match Function
    By kakron21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-09-2011, 05:48 AM
  5. Finding the first and last occurance of a value
    By Jonathan78 in forum Excel General
    Replies: 4
    Last Post: 02-13-2011, 06:22 AM
  6. Finding last occurance as Non-array formula?
    By ratboy505 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-12-2007, 05:45 PM
  7. Replies: 4
    Last Post: 04-17-2006, 06:45 AM

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