+ Reply to Thread
Results 1 to 4 of 4

How to count PASS/FAIL cells in a range...

  1. #1
    Registered User
    Join Date
    08-04-2010
    Location
    CA, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    How to count PASS/FAIL cells in a range...

    Hi. I have a test log with PASS/FAIL. These results are logged in Excel under the column heading PASS/FAIL.
    How do I count the number of PASS or FAIL using VBA macro?

    So far I have tried:
    Please Login or Register  to view this content.
    This one did not work either:
    Please Login or Register  to view this content.
    the error is at the name = Range("PASS/FAIL").Select line.

    My thought process: once I had selected a range, I can now freely "look" at each string in a cell in that range. Not correct I guess.

    Please advice. thank you.

    p.s. all this is currently done in the active sheet.
    Last edited by dtvonly; 05-12-2014 at 11:49 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: How to count PASS/FAIL cells in a range...

    Hi, dtvonly,

    you may use CountIf to check the number for each item, CountA if only values are in that range, get the last cell via

    Please Login or Register  to view this content.
    if you have the header in row 1.

    The command you tried to use assumes that there would be a range being named like that which my Excel doesn´t allow.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: How to count PASS/FAIL cells in a range...

    Error at line Range("PASS/FAIL").Select line is because the PASS/FAIL is not valid Named Range. I assume that PASS/FAIL is a named range in your code which you are referring to. If this is the case change this to a valid Named Range like Pass_Fail and then you can try the following code to get the count......
    Please Login or Register  to view this content.
    or like this.......

    Assuming that column C contains the Pass or Fail. If not, change the column C in red color to the column of your choice in the code.

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,190

    Re: How to count PASS/FAIL cells in a range...

    2 ways...if you want to use a formula
    put a value in col C for pass, and col D for FAIL, using =IF(B2="PASS",1,"")
    then sum the columns
    or
    else VBA code:
    Please Login or Register  to view this content.
    Last edited by ranman256; 05-12-2014 at 12:16 PM. Reason: spellg

+ 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. How to make a cell display "FAIL" when range of cells is FAIL
    By crazychile in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-18-2017, 04:13 PM
  2. [SOLVED] Need a formula for pass/fail based on no. of Y answers but automatically fail if 3a is N
    By Researcher1111 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-15-2013, 10:20 PM
  3. Replies: 5
    Last Post: 03-16-2010, 07:05 AM
  4. Replies: 13
    Last Post: 09-29-2008, 10:36 AM
  5. Replies: 1
    Last Post: 06-10-2005, 08:05 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