+ Reply to Thread
Results 1 to 12 of 12

How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

  1. #1
    Registered User
    Join Date
    12-07-2016
    Location
    Illinois
    MS-Off Ver
    2010
    Posts
    26

    How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    I am creating a spreadsheet that tracks when specific cleaning tasks are performed. The spreadsheet will have columns numbered 1-365 corresponding to each day of the year (1=January 1st). Each task will have a specific frequency for which it should be performed. The employee will input their initials in the cell corresponding to the task and date that they complete a task. Shown below.

    1 2 3 4 5 6 7 8 9 10
    Area/Location Frequency
    West Cooler Weekly SS SS

    I need a way to keep running counts of the amount of times that the task was completed on time and the amount of times that it was not. I will use these counts to calculate on-time completion percentages for given tasks over the course of the months/year.

    My initial thought is to create a formula that counts the number of blank cells between two cells containing values, in a given row. Using a weekly frequency for example, any instance of >6 consecutive blank cells between 2 cells containing initials indicates that the task was not completed on time. Is there a way to do this such that the formula scans an entire row and returns a count of the total number of instances where there were >6 consecutive blank cells? Likewise, I would need to keep a running total of the number of instances where there were <=6 blank cells between two cells containing initials (task completed on time). All help is much appreciated!

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Formula would be something like below. Confirmed as array (Ctrl + Shift + Enter).

    =SUM(IF(FREQUENCY(IF(B3:AU3="",COLUMN(B3:AU3)),IF(B3:AU3<>"",COLUMN(B3:AU3)))>=6,1,0))

    Adjust range as needed.

    Edit: If you want to have entire year range set up before hand, you'll need to subtract 1 from above (if more than 6 days are left in the year from current date).
    Last edited by CK76; 12-07-2016 at 02:06 PM. Reason: See Edit:

  3. #3
    Registered User
    Join Date
    12-07-2016
    Location
    Illinois
    MS-Off Ver
    2010
    Posts
    26

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    #VALUE! error for the logical tests on the if functions. I think it is because you cannot use a range for the test. It also looks like your two if functions located inside the frequency function return the same value, COLUMN(B3:AU3), so I am not sure how that is supposed to distinguish between >6 and <=6 values.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2502
    Posts
    13,700

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Hi Keats713 and welcome to the forum.

    Did you array enter CK76's formula? The #VALUE! error suggests not.

    Formula would be something like below. Confirmed as array (Ctrl + Shift + Enter).
    Try it and please let us know.
    Dave

  5. #5
    Registered User
    Join Date
    12-07-2016
    Location
    Illinois
    MS-Off Ver
    2010
    Posts
    26

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Yes. When I copy and paste it into my spreadsheet it shows a value of 0. But when I substitute in my range, it shows a value error.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    When the formula is array entered and formula evaluated. You will see Logical test portion return array of TRUE/FALSE.

    This...
    #VALUE! error for the logical tests on the if functions.
    And this...
    But when I substitute in my range, it shows a value error.
    Tells me that, you are not correctly confirming array.

    Follow these steps.

    1. Double click on a cell, paste in formula.
    2. Replace range with your range. But do not leave the cell or hit enter yet.
    3. While still in edit mode, hit CTRT + SHIFT + ENTER key.

    You should see {} (curly brackets) surrounding the formula when the formula is correctly confirmed as array formula.

  7. #7
    Registered User
    Join Date
    12-07-2016
    Location
    Illinois
    MS-Off Ver
    2010
    Posts
    26

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Yep, I forgot to array enter again after I changed the range. Sorry about that. It seems to be working! Thank you.
    Can you please explain to me the role of the 2 if statements within the frequency function? To me it looks like they both have the same return if true and combined they cover all possible ranges, so I am not understanding.

  8. #8
    Registered User
    Join Date
    12-07-2016
    Location
    Illinois
    MS-Off Ver
    2010
    Posts
    26

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Also, here is my last question. My range is 1-365 days, so until I enter a value within 6 days of the 365th day, there is always going to be a long string of blank cells that will add 1 to the calculated total of >6 consecutive blank cells. Is there any way to negate this without subtracting 1 from the equation? I am making the spreadsheet for all of 2017 and I might forget to go back remove the "- 1" at the end of the year.

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Here, have a read of the link on Frequency function (especially about data_array & bin_array)
    http://www.excelfunctions.net/Excel-...-Function.html

    I'll see if I have time to write up more detailed explanation of the entire formula tomorrow.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Is there any way to negate this without subtracting 1 from the equation?
    There are ways, but dependent on your set up.
    I'd imagine that you can check for last non-empty cell in a given row, and use that as condition for subtracting 1.

    Assuming that you have 1~365 in Row1 and checking for Row3...
    =LOOKUP(2,1/(C3:NC3<>""),$C$1:$NC$1)

    Will return value of Row1 that corresponds to last non-empty cell in Row3.

    Explanation of previous formula to come later.

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Ok here goes.
    Condition changed to >=2 and range shrunk for demo purpose. Same principle applies.

    Range set up like below image.
    Range.PNG

    Formula: Array Confirmed
    =SUM(IF(FREQUENCY(IF(A1:O1="",COLUMN(A1:O1)),IF(A1:O1<>"",COLUMN(A1:O1)))>=2,1,0))

    Lets take a look at inner IFs first:
    IF(A1:O1="",COLUMN(A1:O1))
    Will evaluate to...
    {FALSE,2,3,FALSE,5,FALSE,7,FALSE,9,10,11,FALSE,13,14,FALSE}

    This is data array portion of FREQUENCY function.

    IF(A1:O1<>"",COLUMN(A1:O1))
    Will evaluate to...
    {1,FALSE,FALSE,4,FALSE,6,FALSE,8,FALSE,FALSE,FALSE,12,FALSE,FALSE,15}

    This is bin array portion of FREQUENCY function.

    So for data array, there are 9 values. {2,3,5,7,9,10,11,13,14}
    In bin array there are 6 values. {1,4,6,8,12,15}

    FREQUENCY can be expressed as # of values in data array that are less than or equal to each bin value and greater than previous bin value.
    Plus # of values in data array that are greater than any bin value.

    Therefore...
    Bin 1 (x<=1) = 0
    Bin 4 (1<x<=4) = 2
    Bin 6 (4<x<=6) = 1
    ...
    Bin 15 (12<x<=15) = 2
    Bin >15 (x>15) = 0

    So FREQUENCY will evaluate to...
    {0;2;1;1;3;2;0}

    Outer IF(FREQUENCY>=2,1,0) evaluate to...
    {0;1;0;0;1;1;0}

    Finally sum is 3.
    Last edited by CK76; 12-08-2016 at 01:33 PM. Reason: Spelling

  12. #12
    Registered User
    Join Date
    12-07-2016
    Location
    Illinois
    MS-Off Ver
    2010
    Posts
    26

    Re: How Can I Count Instances of "x" Consecutive Blank Cells in a Given Row

    Thank you for the awesome explanation and response time. I love seeing the creative ways that these functions can be used to solve problems. You were very helpful. This was my first time using these forums and it definitely won't be the last.

+ 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] Keeping particular cell blank if the related cells show "0" or "blank"
    By Anuru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-24-2014, 05:30 AM
  2. [SOLVED] Replace all BLANK cells in column with header title "Balance" to "0"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2014, 09:25 AM
  3. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  4. Need a formula that will count "consecutive" negative amounts in a row.
    By Scorpvin in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-01-2013, 11:21 AM
  5. Formula returns blanks in some instances instead of the word "blank"
    By tommydollar in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-25-2012, 10:58 AM
  6. Not count "Blank cells"
    By gspot in forum Excel General
    Replies: 4
    Last Post: 03-16-2011, 03:29 PM

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