In Google Sheets, I have a data range that includes 10 cells with a dropdown list of businesses that send us invoices. When any of those cells are marked, meaning we got an invoice that day, we have another range ("Sheet Log!B71:V80) that fills in additional information (date, payment, etc) along with the business name. I have a code that pastes this range to the last row on a different sheet.
// COPIES INVOICES AND PRINTS THEM TO INVOICES SHEET
var invoice_source = ss.getRange ("Sheet Log!B71:V80");
var destInvoiceSheet = ss.getSheetByName("Invoices List");
var destInvoiceRange = destInvoiceSheet.getRange(destInvoiceSheet.getLastRow()+1,1);
invoice_source.copyTo (destInvoiceRange, {contentsOnly: true});
It works fine for the most part, but the next time the function runs and pastes it, it pastes the content to 10 rows down from the actual first empty row. It appears that, even when most of the rows in the Sheet Log range are empty, they are still considered as used rows. This may be because the cells, although showing no info, do have commands on them (IF(cell="","",DATE() as a simplified example.
Is there a way to modify this code to only paste the cells in this range that are NOT blank (in the range's case, not showing "" in the cell?)
I have tried the appendRow() method but it does not appear to work for a range of multiple rows, just the topmost row. I tried implementing a for loop to paste cells that are not equal to "" but I am not the best with Google Apps Script. Best I was able to do was creating a code line to append each row in the range individually but this is very inefficient.