+ Reply to Thread
Results 1 to 11 of 11

Using AND in a range of cells

  1. #1
    Registered User
    Join Date
    07-05-2017
    Location
    Belgium
    MS-Off Ver
    Microsoft 365
    Posts
    32

    Using AND in a range of cells

    Is it possible to use AND with a range of cells?

    AND OK.pdf

    What I would like to achieve is this:

    D1 = "ok" if A1 to A9 are all "ok"
    Values on column A can be "ok," "not ok"

    I can use AND but the problem is, if I have to check 20 cells, my formula will be really long. I was wondering if somebody can help me shorten my formula.

    Thank you very much!

  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,363

    Re: Using AND in a range of cells

    Try

    =IF(Countif(A1:A9,"OK")=9,"OK","Not OK")

  3. #3
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Using AND in a range of cells

    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  4. #4
    Registered User
    Join Date
    07-05-2017
    Location
    Belgium
    MS-Off Ver
    Microsoft 365
    Posts
    32

    Re: Using AND in a range of cells

    Thanks to John and Shukla.

    What if I have more values "ok" to check on the sheet. Say A15 to A20, how would I do that then?

    Thanks again!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,442

    Re: Using AND in a range of cells

    Just extend the range and the count in the formula:

    =IF(COUNTIF(A1:A15,"OK")=15,"OK","Not OK")

    You could also try this:

    =IF(COUNTA(A1:A15)=COUNTIF(A1:A15,"OK"),"OK","Not OK")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    07-05-2017
    Location
    Belgium
    MS-Off Ver
    Microsoft 365
    Posts
    32

    Re: Using AND in a range of cells

    Thanks AliGW.

    But what I actually meant was: what if my ranges are separate? Like A1:A9 and then A20:A26?

    Thanks!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,442

    Re: Using AND in a range of cells

    OK, so what is the test if the ranges are separate? What are we looking for?

  8. #8
    Registered User
    Join Date
    07-05-2017
    Location
    Belgium
    MS-Off Ver
    Microsoft 365
    Posts
    32

    Re: Using AND in a range of cells

    2018-03-28_13-21-47.pdf

    Please see attached image.

    So, D1 = "ok" if A1 to A9 and A13 to A20 are "ok" otherwise D1 = "not ok"

    Possible values on A1:A9 and A13:A20 are "ok" and "not ok"

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,442

    Re: Using AND in a range of cells

    Try this:

    =IF(AND(COUNTA(A1:A9)=COUNTIF(A1:A9,"OK"),COUNTA(A13:A20)=COUNTIF(A13:A20,"OK")),"OK","Not OK")

    PS Don't need an image for that - my imagination can run to two arrays of OKs.

  10. #10
    Registered User
    Join Date
    07-05-2017
    Location
    Belgium
    MS-Off Ver
    Microsoft 365
    Posts
    32

    Re: Using AND in a range of cells

    Great! Thanks a lot!

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,442

    Re: Using AND in a range of cells

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Replies: 4
    Last Post: 02-06-2017, 10:20 PM
  2. Replies: 6
    Last Post: 09-16-2016, 03:52 PM
  3. [SOLVED] Lock/Unlock range cells based on text value in other range cells
    By boboivan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2014, 12:50 PM
  4. [SOLVED] Macro needed to clear cells in range based on value of cells in another range
    By msmith7113 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2013, 12:32 AM
  5. [SOLVED] VBA Copy a range of cells values using the range of cells in a formula (which will change)
    By murtaep in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 06-05-2012, 07:59 AM
  6. Replies: 2
    Last Post: 05-31-2012, 05:37 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