Search code examples
google-sheetsnullgoogle-sheets-formulaspreadsheet

How can I know if a column contains empty cells in Google Sheets?


I'm probably missing something because it seems like a basic question to me but I couldn't find anything related online. Context: I'm creating a spreadsheet to keep track of my expenses which is a simple table with these columns { Description, Category, Date, Amount }. I forget to input some of these field when I register a new expense sometimes. So the question is: how can I check for blank cells (the ones I forget to input) in a given column? I obviously want to ignore all the empty ones that there are after the last valid cell at the bottom of the column.

This is the only formula I've tried: =ISBLANK(A1:A) but it doesn't work as expected because it works only with single cells and not with column. Or at least this is what I've understood.


Solution

  • This is no way usurps doubleunary's superb answer, but if you simply want to know if a column has some empty cells prior to the last filled cell, you could use the following (e.g. for column A):

    =ArrayFormula(countblank(offset(A:A,,,xmatch(1,n(A:A<>""),0,-1)))>0)
    

    n(A:A<>"") returns an array of 1 for filled cells & 0 for empty ones. xmatch(1,n(A:A<>""),0,-1) finds the index of the last filled cell in this array by searching it bottom-to-top for the first 1 it encounters. This index is then fed into offset as the height parameter to return the original A:A range truncated to the last filled cell. countblank then simply counts the number of blanks in this truncated range, and if it is >0 returns TRUE as there are therefore blank cells present.