You're missing a lot if you haven't used these 10 Google Docs templates
Performing repetitive data entries and tasks in Google Sheets can be time-consuming and unproductive. While there are several ways to automate your workflow in Google Sheets, Google Apps Script remains the most effective one of the bunch. It's a powerful solution to boost productivity and elevate your Google Workspace setup in no time. Whether you are looking to generate custom reports, create functional tables, custom functions, or integrate Sheets with other Google services, Google Apps Script can help you achieve it.
In this post, we will dive into the world of Google Apps Script, its potential for automating various Google Sheets Tasks, and step-by-step instructions to manage your existing projects and scripts. Whether you are a project manager, data enthusiast, or business analyst, unlock the world of possibilities with Google Apps Script.
Related
10 cool projects you can do with just Microsoft Excel
Excel-erate your creativity beyond boring spreadsheets
What is Google Apps Script?
Apps Script is a must-have tool for both beginners and experienced developers. It's basically a scripting platform from Google that automates various tasks across all the Google Workspace apps like Sheets, Slides, Docs, and Gmail.
Google Apps Script uses JavaScript code and can be an ideal solution for programmers to enable automation, customization, web applications, add-ons, and even build integration across Google services and products. You can write small programs to enhance standard features in Google Sheets.
If you are frequently juggling formulas, manually updating Google Sheets, or managing a labyrinth of data, you can create automated workflows with Google Apps Script and sprinkle a dash of magic into your spreadsheets. Without further ado, let's get started.
Related
Should you use Google Drive, OneDrive, Dropbox, or Nextcloud?
Analyzing top cloud storage solutions: A deep dive into Google Drive, OneDrive, Dropbox, and Nextcloud
How to access Google Apps Script?
There are a couple of different ways to access Apps Script. You can either visit Google Apps Script home and select the Start Scripting button to access the main interface. You can view all of your projects, shared ones, and even favorite projects from the sidebar. Now, select New project to start writing a custom script for your Google Sheets tasks.
You can access the same interface from within your Google Sheets, too. Follow the steps below.
Open an existing spreadsheet or create a new one in Google Sheets. Select Extensions at the top and click Apps Script to open the same editor as discussed above.
Before we go further, poke around and familiarize yourself with the Apps Script editor if you haven't yet done this.
Write and save your Google Apps Script
Now that you have the basic idea of Google Apps Script and how to access it, use the steps below to write a custom script in it. In the example below, we will open our Italy trip sheet, remove all the drop-down menu bars under the Day, Date, and City columns, and convert them all into a simple table for a better viewing experience. Let's get started.
Open an existing spreadsheet in Google Sheets and head to the Apps Script menu (refer to the steps above). We deleted the existing code and entered a code below to convert the sheet into a table.
function createTable() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Assuming your data is in 'Sheet1'
const lastRow = sheet.getLastRow();
const lastColumn = sheet.getLastColumn();
const range = sheet.getRange(1, 1, lastRow, lastColumn);
const data = range.getValues();
// Create a new sheet for the formatted table
let tableSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Formatted Table");
if (!tableSheet) {
tableSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet("Formatted Table");
}
// Clear any existing content on the table sheet
tableSheet.clear();
// Set table headers and format
tableSheet.getRange(1, 1, 1, lastColumn).setValues([data[0]]).setFontWeight("bold");
// Fill table data and format
tableSheet.getRange(2, 1, lastRow - 1, lastColumn).setValues(data.slice(1));
// Apply table borders and format
const tableRange = tableSheet.getRange(1, 1, lastRow, lastColumn);
tableRange.setBorder(true, true, true, true, true, true); // Add borders
tableRange.setHorizontalAlignment("center");
tableRange.setVerticalAlignment("middle");
tableRange.setFontFamily("Arial");
// Auto-resize columns for better readability
tableSheet.autoResizeColumns(1, lastColumn);
}
read more
Now, let's save and run the script to simplify your spreadsheet.
Run Apps Script in Google Sheets
Apps Script comes with several security protections to eliminate the risk of unverified apps. That's why when you save a script for the first time, it asks for authorization.
Once you write a script and click Save at the top, a dialog box pops up for authorization. Select Review permissions. Choose your authorized Google account.
It opens a permission page to let the Google Apps Script project access your Google account. That way, it can read your saved files and make changes accordingly. Make sure to select Allow; otherwise, your script won't be able to interact with your spreadsheet or perform any action.
Your script is all set to use. Click Run. When you first run a script, it may trigger a warning: app isn't verified. You need to select for it to continue since you are the creator of the app script, and it's safe to use on your account. When you click Run, it starts execution under the Execution log and displays a message Execution completed with exact time.
Now, open Google Sheets and check out your changes in action. The script added another sheet called Formatted Table. This is just one example of writing and running a script to automate repetitive tasks in Google Sheets. You can create different scripts, save and organize them under different projects, and become a spreadsheet ninja in no time.
Close
Related
You're missing a lot if you haven't used these 10 Google Docs templates
Complete your Google Docs documents in no time with these must-have templates
Manage your Google Apps Script creations
At any point, you can manage, edit, and share your scripts.
Head to Google Apps Script home and select My Projects on the sidebar. Click the three-dot menu beside a script to open the project overview menu. You can save it as a favorite for easy access, open it for making changes, rename or delete it, and select Share Sheet + Script to share it with others.
Google Apps Script use cases in Google Sheets
Are you still of two minds about utilizing Apps Script in Google Sheets? Here are some of the top functionalities you can gain by mastering Google Apps Script.
Automatic data entry, such as the ability to extract data from emails and update your Sheets instantly Data cleanup and formatting, where you can ensure standard formatting, remove duplicates, and convert data between formats Calculations and analysis to create custom functions and generate summaries based on your data Integration with other Google services to export your spreadsheet data to Google Forms and Gmail
Enjoy Google Sheets on autopilot
Google Apps Script is a powerful scripting language that creates custom functions and builds dynamic workflows in Google Sheets. The possibilities are endless here. There is unlimited potential as wide as your use cases and skills to begin to write custom scripts that automate complex tasks in seconds.
Apart from Google Apps Script, Google One AI Premium subscribers can also unlock the company's AI chatbot in Sheets to really boost workflow and automation. The paid plan comes with Gemini Advanced integration in all Google Workspace apps, including Google Sheets. Check out our separate guide to learn more about Google Gemini Advanced.