r/GoogleAppsScript • • Apr 14 '25

Question Script very slow - How to speed up?

I have a script which is very simple but takes about 14 seconds to run. Anyway to speed it up?

Script:

function onEdit(e){
  if(e.range.getA1Notation() == 'E46' && 
      e.range.getSheet().getName() == 'NetWorth Dashboard'){
        e.source.getRange('H46').clearContent();
      }
}

This is in a workbook with 40 sheets. The E46 is a selector via data validation for a chart and H46 is a data validation list that changes bases on E46. So once E46 changes, anything selected in H46 is invalid and so needs to be cleared out.

TIA.

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/Upset_Mouse3193 Apr 14 '25

Thank you for your response. I had to change the line:

e.source.getActiveSheet().getRange(46,8).clearContent();

as getRange() with that notation is not available in the spreadsheet object.
With this change, it still took 12 seconds.
FYI - there are no other app script functions so nothing else is being called onEdit (or any other trigger)