Skip to content

Instantly share code, notes, and snippets.

@mutsuda
Created February 23, 2020 21:21
Show Gist options
  • Save mutsuda/541144cadee0918e7e5e41981052afcb to your computer and use it in GitHub Desktop.
Save mutsuda/541144cadee0918e7e5e41981052afcb to your computer and use it in GitHub Desktop.
Google Spreadsheet Financial Snapshot
function snapshot() {
// Assign 'today' today's date.
var today = Utilities.formatDate(new Date(), "GMT+1", "dd/MM/yyyy");
// Assign 'dashboard' the Dashboard sheet.
var dashboard = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Dashboard');
// Assign 'new_row' the first available row to write in.
var new_row = dashboard.getLastRow() + 1;
// Assign to variables the cells where we have the info we want to snapshot.
var cell_stock = "B2"
var cell_funds = "C2"
var cell_crypt = "D2"
// Assign to variables the column where we want to copy every value.
var c_date = 1;
var c_stock = 2;
var c_funds = 3;
var c_crypt = 4;
// Write every piece of information in the column it belongs in the 'new_row'
dashboard.getRange(new_row, c_date).setValue(today);
dashboard.getRange(new_row, c_funds).setValue(dashboard.getRange(cell_funds).getValue());
dashboard.getRange(new_row, c_stock).setValue(dashboard.getRange(cell_stock).getValue());
dashboard.getRange(new_row, c_crypt).setValue(dashboard.getRange(cell_crypt).getValue());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment