Search code examples
excelexcel-formulaexcel-2010excel-2016excel-2019

Count Blank Cells Until Value is Found


How can I find a count of blank cells until a value is found in a row?
I did some searching and found that I could use either
COUNTBLANK with INDIRECT or COUNTIF or MATCH with INDEX

But couldn't get it to work on any of them...

The formula should go into B5.
Example:

enter image description here

Thank you for the help.


Solution

  • Use MATCH() Function:

    =MATCH(FALSE,ISBLANK(B1:F1),0)-1
    

    That formula will give you the number of cells to the first non-blank cell, so if you substract one you’ll get the number of blank cells. As is an array formula confirm it with CRTL+SHIFT+ENTER instead of ENTER so you get the brackets {} in the formula:

    {=MATCH(FALSE,ISBLANK(B1:F1),0)-1}