It doesn't impact the working of code, but it's both pointless and wrong ` var column = main_A.getRange('A1:A').getValues(); var lastRow = column.filter(String).length;` This should correctly find the last non-empty row in column A