Adding automatic timestamps when someone enters data in a specific column (like Column C) is a super useful feature in Google Sheets—especially for tracking when items, orders, links, or tasks were added or updated. The built-in onEdit trigger works great for one sheet, but what if you have multiple input sheets (e.g., “shopdop.insta”, “Orders”, “Paan Flavor”, etc.) and you want the same timestamp logic to apply to all of them?
This guide explains exactly how to modify a simple onEdit script so it runs only on selected sheets (or all sheets), only in Column C, starting from row 5, and adds a permanent timestamp in Column D the first time a value is entered.
Why You Might Need This
- You have several “input” sheets where team members or you add data (links, product names, notes, etc.).
- You want a reliable, one-time timestamp in the next column (D) that never changes—even if the row is edited later.
- You pull this data into a master sheet using
IMPORTRANGE, so timestamps need to be static and accurate. - Manually copying formulas or timestamps across sheets is tedious—this script automates it across multiple tabs.
Option 1: Run the Script on Specific Sheets Only (Recommended – Clean & Controlled)
This is the most common and safest approach: list the exact sheet names where you want the timestamp to work.
Step 1: Open Apps Script
- Go to your Google Sheet → Extensions > Apps Script.
Step 2: Paste & Customize This Code
Replace any existing code with:
function onEdit(e) { var range = e.range; var sheet = range.getSheet(); // List ONLY the sheets where you want timestamps to be added var allowedSheets = ["shopdop.insta", "Orders", "Paan Flavor"]; // ← Change these to your actual sheet names (case-sensitive!) // If the edited sheet is not in the list → stop if (!allowedSheets.includes(sheet.getName())) return; // Only work in Column C (column number 3) if (range.getColumn() !== 3) return; var row = range.getRow(); if (row < 5) return; // Only rows 5 and below var newValue = range.getValue(); var timestampCell = sheet.getRange(row, 4); // Column D = column 4 // If the cell now has a value AND timestamp column is still blank → add timestamp if (newValue !== "" && timestampCell.isBlank()) { var now = new Date(); timestampCell.setValue(now); timestampCell.setNumberFormat("dd/mm/yyyy hh:mm:ss"); // Change format if needed }}
Step 3: Customize the Sheet List
Update the allowedSheets array with your real sheet names:
var allowedSheets = ["shopdop.insta", "variant_redbulls", "Orders9999", "Paan Mixing"];
- Names are case-sensitive — copy-paste exactly from the tab names.
- Add or remove as many as you want.
Step 4: Save & Set Trigger
- Click the floppy disk to save.
- If not already done: Click the clock icon (Triggers) → + Add Trigger
- Choose function:
onEdit - Event source: From spreadsheet
- Event type: On edit
- Save and authorize (Google will ask for permission once).
How it works now
Whenever someone types (or pastes) a value into Column C (row 5 or below) in any of the listed sheets, Column D in that same row gets a permanent timestamp—only the first time. Later edits to the row won’t overwrite it.
Option 2: Run on Every Sheet in the Spreadsheet (Future-Proof)
If you frequently create new sheets and want the timestamp logic to apply automatically to all of them (without editing the code every time), remove the sheet check entirely.
function onEdit(e) { var range = e.range; var sheet = range.getSheet(); // No sheet restriction — works on ALL sheets if (range.getColumn() !== 3) return; var row = range.getRow(); if (row < 5) return; var newValue = range.getValue(); var timestampCell = sheet.getRange(row, 4); if (newValue !== "" && timestampCell.isBlank()) { var now = new Date(); timestampCell.setValue(now); timestampCell.setNumberFormat("dd/mm/yyyy hh:mm:ss"); }}
Use this if your workbook has many similar input sheets and you don’t want to maintain a list.
Important Tips & Customizations
- Where to put the script
Put it in the input workbook (the one with “shopdop.insta”, “Orders”, etc.), not the master sheet that pulls viaIMPORTRANGE. The script only needs to run where the actual editing happens. - Change timestamp format
Edit this line to match your preference: - Date only:
"dd-mm-yyyy" - Time only:
"hh:mm:ss" - With AM/PM:
"dd/mm/yyyy hh:mm AM/PM" - Indian style full:
"dd-MM-yyyy HH:mm" - Common issues & fixes
- Timestamp not appearing? → Check trigger is set and authorized. Test by typing in Column C.
- Timestamp changes on edit? → The
isBlank()check prevents overwrites. - Script slow? → It only runs on Column C edits → very lightweight.
- Error on save? → Make sure sheet names in array match exactly (including spaces/case).
This small script turns your multi-sheet workbook into a much more trackable system—perfect for order tracking, content uploads, flavor mixing logs, or any workflow where knowing “when was this added?” matters.
Try it out! Tell me how many sheets you’re targeting and their names if you run into any issues—I can tweak the code further.
Leave a comment