+ Reply to Thread
Results 1 to 9 of 9

Formula that looks in range and returns Pass if all cells contain Ps

  1. #1
    Forum Contributor
    Join Date
    02-07-2016
    Location
    England
    MS-Off Ver
    2019
    Posts
    270

    Formula that looks in range and returns Pass if all cells contain Ps

    Hi All,

    I am looking to adapt the following formula.

    Please Login or Register  to view this content.
    At the moment this formula looks in the range and returns Pass if all cells contain P and if they are all blank nothing is returned. I was wondering if it was possible to make it if they are all blank no value is returned but if say if only one cell has P in it it returns the value fail.

    Thanks

    If you need any further information please let me know i will upload a example book if needed.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,277

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    Try

    =IF(COUNTIF(R4:T4,"P")=COLUMNS(R4:T4),"Pass",IF(COUNTIF(R4:T4,"P")=1,"Fail",""))

  3. #3
    Forum Contributor
    Join Date
    02-07-2016
    Location
    England
    MS-Off Ver
    2019
    Posts
    270

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    Thanks John that worked a treat, I have now got a column where an X is also added to the mix, i tried this code but it does not seem to work

    Please Login or Register  to view this content.
    Have you got any suggestions?

    Thanks

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,277

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    I assume an OR condition i.e either P or X present...

    =IF(COUNTIF(R4:T4,"P")=COLUMNS(R4:T4),"Pass",IF(OR(COUNTIF(R4:T4,"P")=1,COUNTIF(R4:T4,"X")=1),"Fail",""))

    Typo in first submission

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    If I'm understanding correctly, the conditions are

    ALL P = Pass
    ALL Blank = nothing
    ANY OTHER combination of blanks P or X = Fail

    Right?

    Try
    =IF(COUNTA(R4:T4),IF(COUNTIF(R4:T4,"P")=COLUMNS(R4:T4),"Pass","Fail"),"")

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    Maybe this array formula**:

    =IF(AND(R4:T4="P"),"Pass",IF(OR(R4:T4<>""),"Fail",""))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Contributor
    Join Date
    02-07-2016
    Location
    England
    MS-Off Ver
    2019
    Posts
    270

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    Jonno, your understanding is correct. The code you provided still shows up as fail if all cells are blank.

    Tony - This formula seems to do the trick! I will test it on a few more cells and let you know the outcome.

    Thanks ALL!

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,277

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    Formulas fail if cell has a space rather blank(Null)

    try

    =IF(SUM(COUNTIF(R4:T4,{"P","X"})),IF(COUNTIF(R4:T4,"P")=COLUMNS(R4:T4),"Pass","Fail"),"")

  9. #9
    Forum Contributor
    Join Date
    02-07-2016
    Location
    England
    MS-Off Ver
    2019
    Posts
    270

    Re: Formula that looks in range and returns Pass if all cells contain Ps

    Thank you all!!

+ 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] Formula that returns all cells with data within a selected range
    By Jamidd1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-27-2016, 06:30 AM
  2. SQL Query runs as pass-through but VBA returns error
    By icyrius in forum Access Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2016, 07:36 AM
  3. [SOLVED] Formula that returns Pass if 3 cells have the value of P
    By Jamidd1 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-17-2016, 07:00 AM
  4. Replies: 4
    Last Post: 04-12-2015, 02:47 AM
  5. How to count PASS/FAIL cells in a range...
    By dtvonly in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2014, 12:16 PM
  6. Use if statement for a range +4 and -4 and write PASS / NOT PASS
    By alexistkd in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2013, 07:11 PM
  7. Replies: 13
    Last Post: 09-29-2008, 10:36 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