I have a system generated spreadsheet that enters blank cells when there is more than one item inside an order number. For example, if Order 1 had three items, I would have three rows completely filled but only one with date. The header is like this:
Order Number | User | Date | Item
I Attached an example image from a sample dataset:
I tried the following code which does the job greatly but I couldn't finish the task because the execution is timing out every time the script is run (it stops around row number 1,000). My spreadsheet has about 3,000 rows and growing slowly. I read some instructions about trying to make the code more efficient but for me it is already very efficient (at least comparing it to VBA). Any assistance is appreciated!
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var last = sheet.getLastRow();// get last row number
for (i = 2; i < last; i++) {
var info = sheet.getRange(i, 3);
Logger.log(info);
if (info.isBlank()) {
var data = sheet.getRange(i-1, 3).getValues(); //copy value from cell above with date
sheet.getRange(i, 3).setValues(data); //paste value on empty cell
}
}
}