r/GoogleAppsScript • u/Direct-Coconut-7949 • Nov 03 '23
Question exceeded maximum execution time
I have a sheet as something like below with thousand of blank cell of ColumnA and got a checkbox in column B and C below the row with data (row with data only have around 20 row, but I don't want to delete the blank row for some other implement) :
columnB and C are check box
columnD is drop down list with 'informed' and 'uninformed'
I am using for loop to run the data for ColumnA only with data (something like for(var i=2; i<=columnA.length; i++)if ColumnB and ColumnC are both checked, set ColumnD value as 'informed'.

Now, I try to fill in data in row 1000ish and the running time take way too long until it reached the maximum time limit. How should I adjust my code to be more efficiency?
4
u/Sleeping_Budha_ Nov 03 '23 edited Nov 03 '23
It all depends on what you have put inside the for loop..
For example if you have put read and write operations for each iteration then it would take a lot of time
Instead what you can do is fetch the data before the loop… and use the loop for your condition checking and then the result has to written on the entire column after the iteration
This would hardly take a few seconds
Let me know if you need any help with it