Google-sheets – Use countblank to count number of blank merged cells in Google Sheets

google sheetsgoogle-apps-script

I am trying to get the number of empty merged cells in a range, say for example the 6-cell range of A1:F1. If the cells weren't merged, I could simply use =COUNTBLANK(A1:F1), but let's say A1:C1 are merged and D1:F1 are also merged. If I have a value in A1:C1, =COUNTBLANK(A1:F1) will output 5 instead of the desired 1.

I'm working in a Google Sheets worksheet that was heavily formatted by the designer to be the output of other data in the spreadsheet. The design uses a lot of merged cells and unfortunately getting rid of them is not an option.

The actual spreadsheet has 60 columns by about 400 rows, and the number of merged ranges in each row varies from 1 (i.e., all 60 columns) to 13 (a header column + 12 data columns), so the method I'm looking for ideally would be able to handle that kind of row-to-row variation (which also limits the practicality of formulas like =COUNTBLANK({A1,D1}) which would work perfectly well in the simple example above).

Any way to accomplish this?

Best Answer

Instead of using A1:F1 use {A1,D1}. The final formula is

=COUNTBLANK({A1,D1})

{A1,D1} is an array having 1 row two columns.

NOTE if your spreadsheet uses a dot as decimal separartor instead of a comma use a slash