+ Reply to Thread
Results 1 to 12 of 12

Trying to count non blank cells in an array meeting one condition

  1. #1
    Registered User
    Join Date
    10-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Trying to count non blank cells in an array meeting one condition

    Hello,
    I am attempting to write a formula that searches for a text string say "apples" in Column A. If it finds the string, it would count non-blank cells in Columns B-E and return that result. So if Col B-E all were non-blank, result would be "4". If only col B and col E were non-blank, result would be "2". Stuck with not being able to use CountA or DcountA to solve this.

    BTW, I setup the dataset so that the text string should only appear once (ie only one row) in Col A

    thanks

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Trying to count non blank cells in an array meeting one condition

    have you tried =COUNTBLANK(B2:E2)?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Trying to count non blank cells in an array meeting one condition

    Assuming you are starting on row 1:
    =IFERROR(COUNTA(B1:E1)*(--FIND("apples",A1)>0),"")
    in F1 and copy down as necessary.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Trying to count non blank cells in an array meeting one condition

    For Row_1...Maybe this?
    Please Login or Register  to view this content.
    EDITED TO INCLUDE THIS ALTERNATIVE:
    If you want to count the non-blank B:E cells in the ONE ROW that contains "apples"
    try this regular formula:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Last edited by Ron Coderre; 06-19-2014 at 09:10 AM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  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: Trying to count non blank cells in an array meeting one condition

    try
    =COUNTA(INDEX(B:E,MATCH("*apples*",A:A,0),0))
    "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
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,503

    Re: Trying to count non blank cells in an array meeting one condition

    must have missed that whole apples thing.
    I kept looking at the second sentence more than the first one. <embarrassed>

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

    Re: Trying to count non blank cells in an array meeting one condition

    Another....
    Please Login or Register  to view this content.
    See if the attached sheet helps.

    **Formula edited.
    Attached Files Attached Files
    Last edited by sktneer; 06-19-2014 at 09:15 AM.
    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.

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

    Re: Trying to count non blank cells in an array meeting one condition

    One way...

    Data Range
    A
    B
    C
    D
    E
    F
    1
    ------
    ------
    ------
    ------
    ------
    ------
    2
    Apples
    X
    X
    2
    3
    Grapes
    X
    X
    X
    0
    4
    Pears
    0
    5
    Apples
    X
    X
    X
    3


    This formula entered in F2 and copied down:

    =SUMPRODUCT((A2="Apples")*(B2:E2<>""))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

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

    Re: Trying to count non blank cells in an array meeting one condition

    Looks like everyone has a different interpretation of the request.

    It might be a good idea to post some sample data and tell us what result(s) you expect.

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

    Re: Trying to count non blank cells in an array meeting one condition

    My mistake. I counted blanks instead of non-blanks...Thanks Tony for providing the correct one.

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

    Re: Trying to count non blank cells in an array meeting one condition

    op says
    searches for a text string say "apples" in Column A
    infering that all of column a should be searched
    then again i may be wrong
    Attached Files Attached Files

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

    Re: Trying to count non blank cells in an array meeting one condition

    Quote Originally Posted by Tony Valko View Post
    Looks like everyone has a different interpretation of the request.

    It might be a good idea to post some sample data and tell us what result(s) you expect.
    Let's try this...

    Do you want a row by row count or do you want a single count that covers the entire range?

+ 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 sum cells meeting row & column condition
    By divi123 in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 07-10-2013, 08:32 AM
  2. [SOLVED] Formula to count number of blank cells for a specific condition in another column
    By Daniel_12 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-30-2013, 07:16 AM
  3. Replies: 8
    Last Post: 01-30-2013, 02:58 PM
  4. Sum all cells meeting condition
    By kamelkid2 in forum Excel General
    Replies: 4
    Last Post: 03-04-2011, 08:42 AM
  5. Count non-blank cells with condition
    By isabella in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-11-2010, 03:59 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