Sub topic 3
Naming versions to mark milestones
This chapter assumes you can share a Google Sheets file, right-click a cell, and open the Apps Script editor from Extensions. It covers naming versions, restoring or copying them, checking one cell's edit history, a combined review workflow, and scripting notes and comments.
Naming versions to mark milestones
Open File > Version history > Name current version, enter a label such as "Q3 final", and select OK. Named versions stand out in the version list, so you can find a milestone without scanning timestamps.
Restoring a version or making a copy of it
Open File > Version history > See version history, select a version, and choose one of two options:
- Restore this version replaces the current content with that version.
- Make a copy saves the old version as a new file and leaves the current sheet unchanged.
Make a copy when you only want to compare.
Checking the edit history of one cell
Right-click a cell and select Show edit history. The panel lists who changed the value and when. Use it when one figure changes unexpectedly.
A review workflow that combines all three
Automating notes and listing comments with scripts
Apps Script can write and read notes, but SpreadsheetApp has no method for threaded comments. Notes are cell-level text only.
function addReviewNote() {
const sheet = SpreadsheetApp.getActiveSheet();
const cell = sheet.getRange('B2');
cell.setNote('Check this figure against the Q3 report.');
Logger.log(cell.getNote());
}To list comments, enable the Drive advanced service, then run:
function listComments() {
const fileId = SpreadsheetApp.getActive().getId();
const result = Drive.Comments.list(fileId, {
fields: 'comments(content,resolved,author/displayName)'
});
(result.comments || []).forEach(function (c) {
Logger.log(c.author.displayName + ': ' + c.content + (c.resolved ? ' (resolved)' : ''));
});
}Exercise
Why is Make a copy safer than Restore this version when you only want to compare?
Show answer
Make a copy saves the old version as a new file and leaves the current sheet unchanged. Restore this version replaces the current content.