I am working with a large Google Sheet file. It has 10 sheets, each large with many sumproducts on them. Is there a way to "turn off" and "turn on" the calculation of the spreadsheet from inside a script function. I do a lot of single cell updating and don't need all the sheets to recalculate. I am assuming Google Sheets is recalculating all associated cells everything every time I update a cell. (I think I am looking for the opposite of .flush(), but not sure)
Also: if anyone knows of a good book that goes over Googles Sheets permissible Script commands, with examples, please let me know.
Related
I'm using a GOOGLEFINANCE formula, but it keeps updating. I would like it to stay a fixed amount once it has been calculated the first time but I can't seem to figure out a way to do that. I tried Googling for the answer but came up empty-handed. I went to File > Spreadsheet Settings > Calculation, but there doesn't seem to be an option there to prevent recalculations, there only exist options to delay them.
It seems that feature is not built into Google Sheets. But maybe someone who is really good at formulas or a script. Can think of a super smart way to do it with a formula or a script?
There is no way to stop a Google Sheets formula, including those that use GOOGLEFINANCE function to recalculate.
You might replace the formula by it's result. One simple way to do this is by doing copy-paste as value only.
P.S. GOOGLEFINANCE data can't be retrieved by Google Apps Script.
Related
Pulling current price change % (Google Finance) with Google Apps Script
I have 50 google sheet files for 50 students. They need to key in their answers in their own google sheet file when they are asked to do so. I have a main google sheet to consolidate their data by using IMPORTRANGE formula. This is my formula:
=QUERY({IMPORTRANGE(...);IMPORTRANGE(...);IMPORTRANGE(...);...},"Select * where Col1 is not null")
I will have 50 IMPORTRANGE in the formula. So as expected, the main google sheet is very lag when the 50 students start to key in their answers at the same time. Sometimes, the formula will show #Value when all the students started to answer the questions at their own google sheet file. I need to keep refreshing the main google sheet so that the data will come out, but it will disappear again in a short while then I need to refresh it again (although it will settle down once most of the students finished answering the questions).
I know that using IMPORTRANGE is really not an efficient way to consolidate their answers in main google sheet file but I don't have other better way.
I tried to write a script so that they can send in their data by clicking the button assigned with the script. However, all the students need to go through the authorization process when they run the script for the first time. They don't know how to proceed when they saw the authorization process (not very good in using computer).
May I know is there any ways or tricks that I can use to solve the IMPORTRANGE issue? Or there are some way to write the script where we are not required to go through the authorization process when we run the script for the first time?
Hope to get some advice and help on this as I couldn't find a better way from Google already. Any help will be greatly appreciated!
If I understood correctly what you are looking is that your spreadsheet show in real-time the data being entered simultaneously on 50 different spreadsheets. I'm afraid that Google Sheets is not the right tool for what you are trying to do the way that you are trying to do it. Basically you have two options : change it or use a different tool.
It's not a good idea to have and array of multiple IMPORTRANGE functions that are being edited simultaneously because while the official docs says that IMPORTRANGE functions are updated every 30 minutes when the source and the spreadsheet having formula are opened at the same time the import is done practically immediately and could happen multiple times during the recalculation making causing it to start over an over again.
Replacing the above array by script might help only if you are open to not have the destination spreadsheet updated on real time as scripts are slow.
Replacing the above array by a program that uses the Google Sheets API also might help only if you are open to not have the destination spreadsheet updated on real time as the spreadsheet refresh.
Regarding running a script without requiring authorization that is only possible when using simple triggers and / or removing all the scopes that require authorization to run. Please bear in mind that you might create installable triggers to run other using the authorization of the user who creates them.
Related
Combining multiple spreadsheets in one using IMPORTRANGE
Why do two users sometimes see different values from importrange?
Multiple IMPORTRANGE
Using that many IMPORTRANGE formulas is definitely a bad idea. What I'd suggest you to do:
keep a list of all your student spreadsheet in your main document
write a script that will browse through all of the spreadsheets from that list and copy/paste values into your main document
create a time based trigger that will run the script every X minutes (or hours), depending on how accurate you want the results to be
This is a simple solution, but efficient. Depending on the amount of data and number of students/spreadsheets you may consider other solutions (like writing a cloud function that will do the same as the script) but I think this will work for your use case
I have put together a rather large script file that does a lot of math. It seems to me that if I place a script variable value on the spreadsheet (setValues()), the whole spreadsheet recalcs (i.e.; it takes awhile to refresh). Is that true?
What if I want to format a cell from script (e.g.; change a number cell to a percentage cell with 3 places)[FormattedSS.getRange(rangecoordinates).setNumberFormat("#.###%");]? When I set the format, does the whole spreadsheet recalculate?
I am new to Google Sheets. In Excel, I could set calculation off. Google sheets does not seem to have that option.
Google sheets has no manual calculation option. You would need to create a formula to check whether to run the rest of the formula. If the output is a single cell you can easily use a circular reference to retain the value.
When it comes to Google App Scripts every time you execute a script there will be an annoying delay, that is just how it works, the App Script should be avoided at all cost in a normal spreadsheet except for when actually necessary.
Google App Script Server -> Google Sheet (delay to send information back and forth)
Google Sheet always recalculates after any change
I am having a Google script that sets values of specific ranges from sheet B to sheet A on a button press.
The code I have works, but it takes about 40 seconds due to the high amount of getValue/setValue usage I guess.
The code seen below is only a snippet. It goes on like this about four times as shown.
I already have a nice solution for copying values from one large range (say A1:Z30 via loops but I can not figure out a solution for this matter here.
Your support is very much appreciated. Thank you in advance.
ratenprogrammmain.getRange("E1:E18").setValues(vorlage.getRange("E13:E30").getValues());
ratenprogrammmain.getRange("B2").setValue(vorlage.getRange("B14").getValue());
ratenprogrammmain.getRange("B5").setValue(vorlage.getRange("B17").getValue());
ratenprogrammmain.getRange("A21").setValue(vorlage.getRange("A33").getValue());
ratenprogrammmain.getRange("B25").setValue(vorlage.getRange("B37").getValue());
ratenprogrammmain.getRange("A28:G33").setValues(vorlage.getRange("A40:G45").getValues());
ratenprogrammmain.getRange("H35").setValue(vorlage.getRange("H47").getValue());
Three ideas how to make your code more effiient
If your sheets are located in the same Spreadsheet you can use the copyTo() method for ranges.
Apps Script Best Practices provides samples how to use batch operations to make you code faster and more efficient.
Advanced Sheets Service allows you to use the Sheets API batchUpdate Request CopyPasteRequest
Google sheets changed the size of data that can be imported using the 'importrange' function in late March. We want to write a formula that can search through all our sheets and identify any that will be affected by Google's latest change.
We know there has been a change, as Importranges we had previously setup, are now returning "... to large" type error.
It appears to a limit of data size, not cells - as we experienced the issue on importrange of only 2 columns, but one contained large amount of HTML code in each cell.
Does anyone know what the data size limit is?
If not, then does anyone have an idea for best way to write a script that can find the limit?
Or next step will be to write a script that can search through our 'network analysis' sheet (sheet/tool that shows all Google sheets that are connected by importrange), and identify those with the importrange issue.
FYI - Google appears to have changed quite a bit relating to Google sheets and apps script.
a) We lost the ability to save changes in a sheet (making it basically unusable), which we think is related to having >50 importranges referencing that sheet (google support advised to avoid >50 importranges going to one sheet).
b) Other change we noticed is that google apps script can definitely now run for longer than the previous limit of 5min. We previously were seeing some scripts, sometimes running >5min, all the way up to a max of 30min. But now we see it consistently on some scripts. We built a tool, that can automatically get a script to 'run again' if it did not complete last time. We have had to tweak that 'run again script', to ensure it does not try to run the script again within 30min of the first run, to ensure that first script is definitely still not running.