Use Google Script to Edit a Google Sheet-- Help, beginner level - google-apps-script

I would like to use google apps script to do a couple edit moves to a google sheet report I get everyday:
merge two pages of the same google sheet together (two of the tabs)
delete the first row (report gives a blank first row I would like deleted)
delete 26 of the 44 columns (there are different columns I don't need)
delete rows with that have a specific customer name
filter order numbers from ascending order
I am learning how to use google apps script and I have beginner level experience with SQL and R, but I feel like all the references for google apps script are overboard for what I would like to do. Thank you for help!
I have been reading so many things online, but like I said before it just seems overboard for where I want to start. If there are any good resources I should look into sending those over is super helpful!

Related

How to solve the limitation of IMPORTRANGE formula in google sheet?

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

How do I delete a container-bound script when a Google Sheet is pointing to multiple?

I have been put in charge to automate several Google Sheets for different teams throughout our organization.
It started out with 1 main template. Easy enough.
That template is copied each time a new project comes in.
Eventually a second template was born off of the original (the original is still used as well though)
Some changes were made to the UI of the sheet and I added additional automation based off of the new columns. All seemed well.
As of last week, when I go to the Script Editor of a sheet I get this window:
Let's say I select the first option. If I edit it and test the code, it doesn't work as expected because it's still pulling from the other 2 scripts!
I don't know when or how this happened.
How can I fix this?
You can manage you script by going to: Google Scripts

A Function that creates a function?

I am not sure whether this is possible. I know it sounds like something a virus would try to do.
I have over 400 Spreadsheets that were created from a template.
I have been asked if it is possible for headings to be frozen on certain sheets.
While I know this is possible, the headings are actually on the third table on the Sheet. As data still needs to be added to the first 2 tables and the 3rd start at row 19, it is not a solution to freeze the top 19 and hide the top 18 rows. Freezing the top 19 will freeze most of the screen.
I was thinking that if the active row was >= 30 then it could automate the hiding of the top 18 rows. Is there a way to automate inserting or exporting code into each spreadsheet, or some other feature I could look at?
As far as you didn't provide any examples nor code samples,
I understand you want to use 1 script over 400 spreadsheets.
Workaround:
Use Drive / Drive API to list and filter all your spreadsheets.
Apply Sheets API for each of your spreadsheets.
Reference:
Drive API > Files: list
setFrozenRows

Delay in changing Google Spreadsheet content via Google apps Script?

I am totally new to Google-apps-script and this may be very poor question
I am making a basic setup using google forms and google apps script
From the responses of form I change my content in Google Spreadsheet accordingly
For example my query from form needed 10000 records to be selected and produced in whole another spreadsheet
I just wanted to know that is there some kind of delay introduced when I set and get values of any cell of spreadsheet on such a large scale? If so on what it depends and how as a programmer can I remove or optimize them?
Thanks is advance!
The Best Practices article by Google is the primary reference for this. The most important advice is to minimize the number of calls to spreadsheet methods by batching operations. So, select a range that contains all the records you need, get them all at once with getValues, process without further interaction with the spreadsheet, and output the result using setValues.
If you follow this advice, 10000 records is still a reasonable amount of data to process by a script.

Display matched dates from range

I'm using a Google Sheet to track student check-in's at school. The office staff would like to have an easy way to display all logged dates for any particular student. I would like to use Apps Script to programmatically display the information because vlookup and index/match get dicey with large data sets.
The problem is I can't seem to find a good solution using Apps Script:
You can't run a script from a hyperlinked cell ("Get dates" or something similar to display a popup based on the row index)
Comments/notes cannot be inserted in Apps Script
Using Sheets formulas, wrong data is returned because of the high number of log entries.
Is there another method I'm missing? Any ideas on how to accomplish this?
To insert a note use range.setNote(note)1
1: https://developers.google.com/apps-script/reference/spreadsheet/range#setnotenote