Created
February 23, 2020 21:21
-
-
Save mutsuda/541144cadee0918e7e5e41981052afcb to your computer and use it in GitHub Desktop.
Google Spreadsheet Financial Snapshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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