+ Reply to Thread
Results 1 to 3 of 3

Count the first occurrence of a substring

  1. #1
    Forum Contributor
    Join Date
    07-18-2012
    Location
    New York
    MS-Off Ver
    2016
    Posts
    192

    Count the first occurrence of a substring

    Hello,

    I'm trying to add a column to a table to use for a sum of the unique items in a pivot table.
    I have seen a couple of formulas that will return a 1 for the first cell and 0 for all others that match, one such formula is

    Please Login or Register  to view this content.
    I need to take this a step further and include a mid formula so that I can have the formula look for specific text within the cell.
    One issue that I'm trying to solve for is that my data is a list of the previous day's emails and the text field I'm looking at is the subject line.
    If I have multiple emails with the same subject I want it to be able to ignore any RE: or FW:.
    I've been playing around and have what I think it should be

    Please Login or Register  to view this content.
    but it doesn't return consistent results. Do I need to have a separate column to parse out the substring first and then use the countif on that?

    Thank you in advance.

    Tristan

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Count the first occurrence of a substring

    Hello,

    you can use Countif with a wildcard.

    =(COUNTIF($A$1:$A5,"*your substring*")=1)+0

  3. #3
    Forum Contributor
    Join Date
    07-18-2012
    Location
    New York
    MS-Off Ver
    2016
    Posts
    192

    Re: Count the first occurrence of a substring

    Quote Originally Posted by teylyn View Post
    Hello,

    you can use Countif with a wildcard.

    =(COUNTIF($A$1:$A5,"*your substring*")=1)+0
    Yes but the substring isn't consistent for every row.

    Until someone has a better solution I basically added a helper column to create my substring and then the countif is referencing the helper column.

    Thank you.

+ 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] Count Occurrence
    By murray83 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-03-2017, 05:13 PM
  2. [SOLVED] count and sum occurrence against a value
    By koshur in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-28-2015, 02:46 AM
  3. Macro to search cells for substring and replace contents of cell if substring is found
    By robbyvegas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2015, 06:40 AM
  4. Macro to count a specific substring within a string
    By Daddy007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-30-2015, 03:25 PM
  5. Count Occurences of text substring
    By barnowl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-03-2013, 10:30 PM
  6. Search substring within range, report the substring found
    By Brooke1578 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-20-2012, 03:56 PM
  7. [SOLVED] Extract Substring, then Ignore that Substring, while collecting data from Other substrings
    By Sameki121 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2012, 05:21 PM

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