Reputation: 1
I am somewhat new to this, so may be I am missing something basic.
Why custom functions in Google Sheets run so low. For example I have 30 rows with data and I want to delete empty rows. The function only runs within this range but I can see function go line by line in real time.
Shouldn't such simple functions happen in a fraction of a second?
Upvotes: -1
Views: 64
Reputation: 7773
Deleting rows is intensive since it's affecting the shape of the spreadsheet rather than just the values in the spreadsheet. Instead of deleting the rows, maybe have your script get all the values, then filter out the empty rows, then clear the sheet and put the values back.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange('A3:Z');
var values = range.getValues().filter(e=>e[0]);
range.clearContent();
sheet.getRange(3,1,values.length,26).setValues(values);
Upvotes: 2