+ Reply to Thread
Results 1 to 9 of 9

How to count instances meeting criteria?

Hybrid View

  1. #1
    Registered User
    Join Date
    04-20-2009
    Location
    bakersfield
    MS-Off Ver
    Excel 2003
    Posts
    10

    How to count instances meeting criteria?

    Gentlemen,
    There is something I want to count in my data. Please look at the file I attached to see my challenge.
    Thank you in advance
    Attached Files Attached Files

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432

    Re: How to count instances meeting criteria?

    Hi guntar,

    Are you looking to use VBA to do this? if so you can loop the cells and count howmany have X in them like so

    Sub GetWstCount()
    Dim c As Range
    Dim counter As Integer
    
    For Each c In Range("G7:G16")
        If c.Value = "X" Then
            counter = counter + 1
        End If
    Next c
    
    MsgBox "There were " & counter & "!"
    End Sub
    There are only 10 types of people in the world:
    Those who understand binary, and those who don't!

  3. #3
    Registered User
    Join Date
    04-20-2009
    Location
    bakersfield
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: How to count instances meeting criteria?

    No, only with functions available in Excel

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: How to count instances meeting criteria?

    Quote Originally Posted by guntar View Post
    No, only with functions available in Excel
    So why post in programming then?

    Thread moved to worksheet functions as per forum rules below

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

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

    Re: How to count instances meeting criteria?

    =countif(k7:k16,"x")
    "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

  6. #6
    Registered User
    Join Date
    04-20-2009
    Location
    bakersfield
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: How to count instances meeting criteria?

    Thank you martindwilson, it works if I would have only one column, but I have more than one “WEST” column. I need something what looks in a range E7:L7 first and then goes down 7:16 rows searching for matching criteria.
    Thank you

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

    Re: How to count instances meeting criteria?

    how many? are they always nswenswenswe and so?
    why not just total all the count ifs?
    use a few helper cells you could always put them on another sheet if you dont want to see them
    Attached Files Attached Files
    Last edited by martindwilson; 04-26-2009 at 05:05 PM.

  8. #8
    Registered User
    Join Date
    04-20-2009
    Location
    bakersfield
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: How to count instances meeting criteria?

    I want to count how many names have been in WEST, there will be more West columns added later, and I want that information to be updated automatically, the end result will feed the Chart.
    Thank you

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

    Re: How to count instances meeting criteria?

    see previous post it has an idea you can extend the ranges if needed
    edit did you say names? if name 1 is in west 10 times did you want 1 or 10 returned?

+ 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