136 posts tagged with “google-sheets”

Clean Cell Text

A lookup that should match "Ada Lovelace" fails because the cell is Ada\u00A0Lovelace with a non-breaking space, or has a zero-width…

Get Cell Links

getValues() gives you the visible text of a hyperlink, not the URL. getCellLinks(range) reads rich text (getRichTextValues, getRuns…

Next Round Robin

nextRoundRobin(key, people, opts) returns the next person in a rotation and remembers that choice in Script Properties. A script lock wraps…

Refresh Slides Charts

A Slides deck with charts linked to a sheet shows yesterday's numbers until something refreshes them. refreshSlidesCharts(presentation…

Copy Formatting From Row

New rows get values easily enough. Matching the fonts, number formats, and fill of your template row is the part people do by hand…

Rows Older Than

rowsOlderThan(rows, dateField, days, opts) returns the row objects whose date field is older than N days, measured in calendar days in the…

With Menu Cooldown

A menu item that archives rows or sends emails is dangerous when someone double-clicks it. withMenuCooldown(key, seconds, fn, opts) runs fn…

Pick Columns

You've turned rows into objects, and now you only need four of the twenty fields, in a set order, for an export, an email, or another tab…

Write Groups To Tabs

writeGroupsToTabs(ss, groups, headers) takes rows grouped by a key, like one group per owner, region, or client, and writes each group to…

Batch Get Ranges

Reading ten ranges with ten getValues() calls means ten round trips. batchGetRanges(spreadsheetId, ranges) reads them all in one call to the…

Protect Row For Editors

protectRowForEditors(sheet, row, keepEmails) locks one row so only the people you list (and you) can edit it. If the row already has a…

Unmerge And Fill Down

Merged cells look tidy, but a script reading them only sees the value in the top-left cell. Every other cell in the block comes back empty…

Get Sheet By Gid

A sheet URL ends in #gid=123456789. That number points at one tab and stays the same when someone renames it. getSheetByGid(ss, gid) finds…

Parse Loose Date

Imported sheets are full of dates that are really text: 03/04/2026, 4 Mar 2026, March 4th, 2026, 2026-03-04. parseLooseDate(value, {dayFirst…

Sum By Key

Total quantity per SKU, spend per vendor, hours per client. sumByKey(values, keyIndex, valueIndex) takes a 2D array with a header row and…

Merge By Key Newest Wins

Two lists of the same people, both partly out of date. mergeByKeyNewestWins(listA, listB, keyField, dateField) merges row objects by a key…

Split Multi Select To Rows

Google Forms stores checkbox answers in one cell: Sheets, Gmail, Docs. Pivot tables and COUNTIF can't count that. splitMultiSelectToRows…

List Calendar Event Rows

You want a week of calendar events on a sheet: one row per meeting, with the duration as a number you can sum. listCalendarEventRows…

Translate Cells

A column of product names or survey answers needs a Spanish copy next to it. translateCells(range, targetLang, opts) reads the range once…

Combine Tabs With Source

Twelve rep tabs, one per person, and a manager who wants one list. combineTabsWithSource(ss, pattern, opts) reads every sheet whose name…

Formula Inventory For Prompt

A sheet with 4,000 formula cells usually has about six distinct formulas, copied down. formulaInventoryForPrompt(range) groups cells by…

Write As Plain Text

Write 00123 to a cell and Sheets stores 123. Write a 16-digit order ID and you get 1.23457E+15, and the last digits are gone for good…

Find Error Cells

A #REF! on tab 9 can sit there for weeks until someone presents the dashboard. findErrorCells(sheetOrSpreadsheet) scans one tab or every tab…

Set Highlight Rule

Run a “highlight overdue rows” script three times and you get three identical conditional-format rules, then thirty. setHighlightRule(range…

Stamp Edit Timestamps

“When was this row added, and when did someone last touch it?” stampEditTimestamps(e, opts) answers both from an edit trigger. It fills…

Set Dependent Dropdown

Pick Category = Hardware in column B and column C should only offer Laptop, Monitor, Dock. Change B to Software and C should switch to…

Send Digest Per Owner

One big “open items” email to the whole team gets ignored. One short email per person, listing only their rows, gets read…

Snapshot Range To History

Formulas only ever show today's number. The MRR cell said 4,200 last month and 4,650 now, but nobody wrote 4,200 down…

Archive Rows Before Date

The orders sheet has 40,000 rows and every script that reads it is slow. archiveRowsBeforeDate(sheet, dateHeader, cutoff, opts) moves every…

Append Status Audit Row

“Who moved this deal to Lost, and when?” Version history can answer that, slowly. appendStatusAuditRow(ss, entry) writes one line to an…

Get Display Row Objects

getValues() gives you what's stored in the cell: a Date object, 0.125, 4500. Sometimes you want what the cell shows: Dec 18, 2026, 12.5%, $…

Diff Objects By Key

“What changed since yesterday?” is a question every sheet eventually gets asked. diffObjectsByKey(before, after, key) compares two arrays of…

Append Dead Letter Row

Some rows just won't go through: a bad email, an API that keeps saying 422, a customer ID that doesn't exist. Retrying them forever clogs…

Sheet Schema For Prompt

Ask any assistant to write a script for “the Orders sheet” and it will happily invent a Customer Email column you don't have…

Escape Leading Formula

You imported a CSV of support notes. One row started with =HYPERLINK(...) (or just =1+1, or a phone number typed as +15551212). Sheets…

Assert Required Keys

The API call failed because row 37 had no email. Worse, it succeeded with an empty amount. assertRequiredKeys(obj, requiredKeys, opts…

Script Write Guard

Your nightly job rewrites 400 rows by row number. Meanwhile someone edits a cell, your installable onEdit auto-sorts the sheet, and the job…

Set Dropdown From List

Status columns full of “approved”, “Approved ”, and “APPROVED!!” break every script that reads them. setDropdownFromList(targetRange, source…

Flush Then Get Values

You write inputs, then read a formula cell that depends on them, and get the old answer. Apps Script batches writes, so the read can run…

Get Visible Row Objects

Ops filter the sheet to “Status = Ready, Region = East” and click your menu item. They expect it to act on what they can see. getValues…

Filter Objects By Date Window

“Rows from the last 7 days” sounds trivial until a row stamped at 11:30pm in New York shows up as tomorrow because something compared…

Get Selected Row Objects

getActiveRowAsObject is perfect for one row. Ops rarely stop at one. getSelectedRowObjects(sheet, headerRow) returns a header-keyed object…

Group Objects By Key

You have 200 rows and need one email (or one Drive folder, or one export) per client. Nested loops and “remember the last name” logic get…

Is Within Business Hours

A time-driven trigger that fires at 3am and emails a client is a support ticket waiting to happen. isWithinBusinessHours(startHHmm, endHHmm…

Copy Values To External Sheet

IMPORTRANGE is great until the client workbook needs a static copy, the source sheet has to stay private, or the formula starts showing #REF…

Stamp Last Successful Run

“Did the nightly job run?” shouldn’t mean opening Executions. stampLastSuccessfulRun(target, status, opts) writes a spreadsheet-timezone…

Write Block Leaving Formula Cols

appendRow and one wide setValues write every column — including the ones holding =VLOOKUP(…) or =IF(…). One run and your formula columns are…

Truncate For Cell

Sheets cells top out around 50k characters. Dump a full err.stack, UrlFetch body, or JSON blob with setValue and the run throws mid-flight…

Open By URL Or Id

Paste a whole browser URL into SpreadsheetApp.openById and the run dies. openByUrlOrId(urlOrId) accepts a Spreadsheet URL or raw id…

Format in Spreadsheet Timezone

Log stamps and export filenames that disagree with the sheet’s timezone are a classic bootstrapper footgun. formatInSpreadsheetTimezone(date…

Sanitize a Sheet Tab Name

setName and insertSheet reject characters Sheets reserves (: \ / ? * [ ]), and long client names blow past the 100-character tab limit…

Claim the Next Queue Row

A sheet full of pending jobs will double-process the moment two triggers overlap. claimNextQueueRow finds the first matching status under a…

Archive rows, don’t delete them

Delete feels decisive until a client asks where order 1842 went. Soft-delete flags help; a dedicated Archive tab is clearer for operators…

Get the Active Row as an Object

Menu actions and sidebar handoffs usually care about the row you're on, not the whole grid. getActiveRowAsObject reads the header row plus…

Copy a Template Sheet Tab

Copying last month's client tab inherits junk formulas, stale sample rows, and mystery filters. Keep a clean template tab, then…

Build a Header → Column Index Map

Hard-coding column letters (C, D) breaks the moment a client inserts a column. Build a { headerName: columnIndex } map once from row 1, then…

Move a Row to Another Sheet

"Delete" is usually the wrong word. Archive the row to another tab (or workbook tab), then remove it from the working sheet — so audits…

Ensure Header Row Exists

Importers and upserts assume row 1 is headers. Empty tabs and "someone deleted column C" both break that. This helper creates the header row…

Upsert a Row by Key Column

Find a row by a key column (email, order ID, SKU) and update it — or append if it's new. Header-aware, so you pass a plain object instead of…

Get the Last Data Row in a Column

getLastRow() happily counts formatting, old formulas, and phantom blanks. When you need the real last cell with data in a column — for…

Convert Sheet Values to CSV Text

Need a CSV string for email attachments, Drive dumps, or API uploads? Escape commas/quotes/newlines correctly, then join rows. These two…

Show a Sheet Toast for Progress

Long-running menu actions feel broken without feedback. SpreadsheetApp.toast pops a small notice in the lower-right — perfect for "started…

Append an Object as a Sheet Row

When your data is already a plain object (API payload, form values), aligning it to row-1 headers beats hand-building arrays. Missing keys…

Clear a Sheet but Keep Header Row

Wiping a sheet before a fresh import is common — but you usually want the header row to survive. This clears content below the header(s…

Get or Create a Sheet by Name

Need a tab that might not exist yet? This helper returns the sheet if it's there, or inserts it and returns the new one — no null checks…

rowsToObjects and objectsToRows

Sheet data is easiest as a 2D array. Business logic is easier as objects keyed by header. These two helpers convert back and forth without…

withDocumentLock Helper

When a time-driven trigger and a manual run can overlap — or two editors kick the same sync — you need a lock. This helper wraps LockService…

Batch writes without timeouts

When a script dies halfway through writing thousands of rows, you don't need a fancier API — you need a boring pattern: lock, chunk…

Get Data from a Sheet

There are a few different ways to get all of the data from a specific sheet. The fastest way is to use the .getDataRange() method. The only…

Auto-Sorting Your Google Sheet

Sorting your Google Sheet using Apps Script is very simple. Firstly, you'll need to decide how you want to sort your data - either by the…

How to Auto Sort your Google Sheet

Welcome to Community Support - where you can get help with hurdles you're facing while bootstrapping your company or trying to find new ways…

How to track time in Google Sheets

Trying to figure out how long it took to complete a task? Use =DATEDIF(start_date, end_date, time_unit) calculate the amount of days, months…