Skip to content

Instantly share code, notes, and snippets.

@sco-tt
sco-tt / GA-sort-two-columns.js
Last active August 5, 2022 05:44
This Google Apps Script sorts two columns. Variables can be modified to define what two columns should be sorted, and whether they should be ascending or descending.
/** Build a menu item
From https://developers.google.com/apps-script/guides/menus#menus_for_add-ons_in_google_docs_or_sheets
**/
function onOpen(e) {
var menu = SpreadsheetApp.getUi().createMenu('Sort');
if (e && e.authMode == ScriptApp.AuthMode.NONE) {
// Add a normal menu item (works in all authorization modes).
menu.addItem('Sort Sheet', 'sort');
} else {
@sco-tt
sco-tt / GA-copy-to-archive.js
Last active March 30, 2021 10:40
This google apps script copies values from a specific sheet within a Google Apps spreadsheet to a master spreadsheet. All values are added a a master acrhive where the name of the source sheet is automatically added as the first column. Additionally, all copy operations are logged in a separate sheet.
/* Menu set-up. From https://developers.google.com/apps-script/guides/menus#menus_for_add-ons_in_google_docs_or_sheets */
function onOpen(e) {
var menu = SpreadsheetApp.getUi().createAddonMenu(); // Or DocumentApp.
if (e && e.authMode == ScriptApp.AuthMode.NONE) {
// Add a normal menu item (works in all authorization modes).
menu.addItem('Copy Values to Master', 'copySheetValues');
} else {
// Add a menu item based on properties (doesn't work in AuthMode.NONE).
var properties = PropertiesService.getDocumentProperties();
var workflowStarted = properties.getProperty('workflowStarted');