So I have a column of data in a sheet, that I am iterating over with an apps script function.
The problem is that my sheet has a number of empty cells at the end, which are rendered as []
when I use .getRange()
.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("AUD Data");
var sheetRange = sheet.getRange("F2:F").getValues();
function logRange() {
Logger.log(sheetRange)
}
I want to get all these blank cells at the end, out of my cell array, as it is messing with results when I loop over this array.
Have tried filter() and isNaN but those solutions didn't work.
Ideally I would like to remove the empty arrays, before looping, but a way of ignoring them in a condition would be fine too.
I find it interesting that even though these empty cells are displaying as empty arrays, Apps Script seems to treat them as having a value. My conditions should ignore imo... eg.
else if (i > 0 && sheetRange[i] <= 0 && sheetRange[i-1] <= 0)
How can an empty array be treated as a number?
NOTE: I can fix this by deleting the empty rows in the sheet, but would rather do this with code.