Coding with Google Apps Script
As a G Suite
TemplateTab is one of my favorite things I’ve coded. In a Google Sheets
Alice Keeler Add-ons
You can find many of my coding projects at
5 Google Apps Script Basics
Each chunk of code is contained in a function. If your coding project has multiple steps you may want to set up multiple functions to allow for different features.
Notice in TemplateTab next to the Help menu is a menu I coded. The menu itself is one function; a set of code to tell the spreadsheet to have a menu. There are multiple options. The main option is to “Run TemplateTab.” That option is a separate function from the function to make the menu. Each menu item is a separate function I wrote.
To create a function in Google Apps Script type the word function in all lower case. If you spelled it correctly it will turn purple. Put a space and then what you want to name your function. It has to be a single word. Notice for TemplateTab that I smooshed the words together to make one word. This is a common technique. Lowercase the first word, capitalize the first letter of any subsequent words.
This is a list of the function names I have for my TemplateTab script. Notice they are all one word.
After deciding on your function name, put a set of parenthesis to contain your parameters. Almost always you have no parameters so your parenthesis are blank. Then you need a set of curly braces to indicate the start and end of the function.
Variables store values so you can reuse values or code without having to retype the same thing you had already typed.
Define a variable by starting with the 3 letters var and then
Want More Help with This? Become a Premium Member
Each line of code needs to end in a semi-colon to tell the script… this is the end of the line of code! This is where coding gets “fun.” You will forget a semi-colon at the end of a line and then your code won’t run and you have to figure out where you forgot the semi-colon.
Extra spaces and extra returns do not affect your code. Space out your code so it’s easier to view and read. Push enter several times to separate out different parts of your code.
Use two slashes // to create a COMMENT. This is like a post it note in your code. Consider pushing enter several times and typing 2 slashes to make a comment about what code is coming next.
5. GOOGLE IT!