I need to delete all empty rows in a sheet using google script. So far I've tried the standard approach:
function removeEmptyRows(){
var sh = SpreadsheetApp.getActiveSheet();
var maxRows = sh.getMaxRows();
var lastRow = sh.getLastRow();
sh.deleteRows(lastRow+1, maxRows-lastRow);
}
This works fine for truly empty rows, but fails when it comes to rows that are occupied by "invisible values" resulting from array formulas, although these formulas use IFERROR(1/0)
.
How do I delete all rows containing blanks?