In my script, users input data and run the script by clicking a button. The script then appends the data to two different tabs and clears the data entry tab. However, I encountered an issue where I had to manually hard code each cell for appending, causing the script to search through empty rows as well. I need help optimizing the script to only target non-empty rows and append those to the next tab in order to reduce execution time. The button function must remain unchanged. Below is the script that appends data from the "Verify" tab:
function verify() {
const mainFunctionName = "verify"; // function name Mf this function.
const alartFunctionName = "alert4";
const drawings = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("VERIFY").getDrawings();
const drawing = drawings.filter((e) => e.getOnAction() == mainFunctionName);
if (drawing.length == 1) {
drawing[0].setOnAction(alartFunctionName);
SpreadsheetApp.flush();
vf();
drawing[0].setOnAction(mainFunctionName);
}
}
function alert4() {
SpreadsheetApp.getUi().alert("NOW SAVING");
}
function vf() {
// Same content as before
}