Your First Google Apps Script Macro (No Coding Experience Needed)
Anything you do by hand in Google Sheets — formatting a report, sorting, inserting a timestamped row — can be done by a script. Google Apps Script is built into every spreadsheet, free, and based on JavaScript. You do not need to know JavaScript to start, because Sheets will write the first draft for you.
Step 1: Record a macro
- Open Extensions > Macros > Record macro.
- Choose relative references if the actions should apply wherever your cursor is; absolute if they should always hit the same cells.
- Do something you repeat often: bold the header row, freeze it, resize columns, add a filter.
- Save it with a name and (optionally) a keyboard shortcut.
That is already useful. But the real value is what happens next.
Step 2: Read the code it wrote
Go to Extensions > Apps Script. You will find a function like this:
function FormatHeader() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('1:1').activate();
spreadsheet.getActiveRangeList().setFontWeight('bold');
spreadsheet.getActiveSheet().setFrozenRows(1);
}
Even with zero coding background you can see the shape: get the spreadsheet, grab a range, do things to it. Recorded code is clunky (all that activate() business) — cleaned up, it reads better:
function formatHeader() {
const sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange('1:1').setFontWeight('bold').setBackground('#f1f3f4');
sheet.setFrozenRows(1);
}
Step 3: Write something a recorder cannot
Recorders cannot do logic. Scripts can. Here is a timestamped log entry added to the top of a sheet — one line per run:
function logEntry() {
const sheet = SpreadsheetApp.getActive().getSheetByName('Log');
sheet.insertRowBefore(2);
sheet.getRange(2, 1, 1, 2).setValues([[new Date(), 'Checked in']]);
}
Step 4: Give it a button
The onOpen function runs automatically when the spreadsheet opens — use it to add your own menu:
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('⚡ My Tools')
.addItem('Format header', 'formatHeader')
.addItem('Log entry', 'logEntry')
.addToUi();
}
Reload the sheet and your menu appears next to Help. Anyone you share the sheet with can use it — no setup on their end.
The first-run permissions dance
The first time you run a script, Google asks you to authorize it, and because your script is not a verified app, you will see a scary "Google hasn’t verified this app" screen. For your own scripts this is expected: click Advanced, then "Go to (project name)". You are authorizing your own code against your own account.
From here, explore SpreadsheetApp in the editor’s autocomplete — reading ranges with getValues(), writing with setValues(), and sending email with MailApp. That last one is where automation gets addictive, and it is exactly where the next post picks up.