+ Reply to Thread
Results 1 to 7 of 7

Counting occurences of a string

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    Earth
    MS-Off Ver
    Excel 2003
    Posts
    6

    Counting occurences of a string

    Hey Guys,

    I tried using counif statement, but that doesn look like it will work.

    What I have is a column with multiple pieces of data and I would like to account for the occurences a certain string appears in the column

    A
    1) 11
    13
    13.1
    12
    ------------------
    2) 13

    So my primary goal would be for the example above is to count all the occurences of just "13"(not 13.1) in column A

    My secondary would be able to use a cell reference in all of this, ie find all occurences of B1

    I look forward to suggestions
    Last edited by Garage23; 07-19-2010 at 04:46 PM.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: Counting occurences of a string

    Hi there,

    The following formula (in whatever cell you choose to house it in) returns the desired result for me:

    =COUNTIF($A$1:$A$4,13)

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    05-13-2010
    Location
    Earth
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Counting occurences of a string

    I think my original post wasn't clear so I attached an example.

    In the attached example I would like to count how any times bfs2 occurs in column A
    Attached Files Attached Files

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

    Re: Counting occurences of a string

    see attached put string in b1 result in c1
    Attached Files Attached Files
    "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

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Counting occurences of a string

    I think you want:

    C1:
    =SUMPRODUCT((LEN($A$2:$A$5&CHAR(10))-LEN(SUBSTITUTE($A$2:$A$5&CHAR(10),$B$1&CHAR(10),"")))/LEN($B$1&CHAR(10)))

    where B1 holds bfs2

    the above will conduct exact matches (ie bfs2.1 not a match)

    assumes a line break delimiter per the example

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

    Re: Counting occurences of a string

    i missed that i thought it was all occurences but having re read original post
    just "13"(not 13.1)
    that looks just the ticket!

  7. #7
    Registered User
    Join Date
    05-13-2010
    Location
    Earth
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Counting occurences of a string

    Thanks for the responses. I used DonkeyOte's solution

+ 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