Skip to content
Advertisement

How to speed up surprisingly slow Google Sheets Apps Script functions that copy formulas from one column to newly inserted column

I have a workbook with multiple sheets, and the main sheet has 123 rows and 90 columns currently.

I’ve coded the following functions (which work) to define an onChange event handler for the INSERT_COLUMN event that automatically populates the cells of the newly-inserted column with the contents of the column immediately to the left. Then it deletes the values of the cells that are not formulas.

It’s painfully slow, and I’m not sure why.

How can I speed this up? Thanks.

JavaScript

Advertisement

Answer

Not sure if I fully understand the problem. So here is a guess.

I’d try to change the function with the fancy name deleteAllValuesAndNotesFromNonFormulaCells() this way:

JavaScript

If you don’t need to keep the notes the function can be boiled down to just one line:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement