Why I'm Using Google Scripts and Why You Should Too
07 Sep 2023TL;DR
Using Google Scripts, I’ve automated and enhanced my Google Sheets tasks. Check out my UsefulGoogleSheetScripts repository for scripts that can revolutionize your Sheets experience. Dive in, save time, and boost efficiency!
In the age of digital transformation, automation is the key to efficiency. When I say this I mean personal efficiency, I hate doing repetative things; so I try finding ways so that technology can help do things that I don’t want to do. Whether it’s automating mundane tasks, streamlining workflows, or enhancing the functionality of your tools, every bit of automation can save you time and reduce the chances of human error. One of the tools I’ve found incredibly useful in my journey towards automation is Google Scripts, especially when working with Google Sheets.
Google Scripts and JavaScript: A Comparative Glance
At first glance, Google Scripts might seem like a whole new language to learn, especially if you’re familiar with popular scripting languages like JavaScript. However, you’ll be pleased to know that diving into Google Scripts is not like starting from scratch. In fact, Google Scripts is quite similar to JavaScript. Here’s how I write a quick and dirty script to do my job:
-
AI Tools: Obviously use AI tools for writing code; use the above to help you debug your code or help find why it is not working. I generally start by asking ChatGPT or Claude to write a starter script on what I want to do and then build on top of the scripts to add/functionality/debug/ add logging etc.
-
Basic Syntax Knowledge: Familiarity with the fundamental syntax of the language, such as:
- Variables (var, let, const)
- Control structures (if, for, while)
- Functions (function keyword or arrow functions)
- Inline Comments: Even if it’s a quick script, a few inline comments can help clarify your logic, especially if you need to revisit the script later
-
Debugging and Logging: If you’ve used console.log() in JavaScript for debugging, you’ll find a similar friend in Google Scripts with the Logger.log() method.
-
Error Handling: While you might skip comprehensive error handling in a quick script, at least have basic checks or try…catch blocks to handle potential pitfalls.
-
Built-in Functions & Methods: A good grasp of the built-in functions and methods can save a lot of time. For Google Scripts, this might mean knowing methods related to Sheets or Docs. For JavaScript, it could be array or string manipulation methods.
My Repository of Useful Google Sheet Scripts
To make things easier for everyone, I’ve created a repository called UsefulGoogleSheetScripts. It’s a collection of scripts I created which I’ve found beneficial, and I believe they can be of use to you too.
Here’s a brief overview of some scripts in the repository:
-
TrackRowEdit.gs: Automatically adds a timestamp whenever a specific column is edited. Great for tracking changes!
-
ProtectFromEdit.gs: Protects a range in your sheet so that only the owner can edit. Essential for maintaining data integrity.
-
AddValueNewSheetEdit.gs: Transfers a value from one sheet to another when edited. Useful for data synchronization.
-
SendEmailData.gs: This script is a lifesaver! It filters data and sends me an email based on those filters. I use it to automate my To-Do lists, ensuring I never miss a task.
Collaboration is Key
The beauty of this repository is that it’s collaborative. If you’ve got a script that’s been a game-changer for you, consider contributing. PRs are welcome! I started this as a way to ensure no one has to reinvent the wheel. Instead of googling for scripts, you can find a curated list right here.