Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is a script to help with automatically roll over at the end of
- an operating round. The script comes in two parts:
- - add a new menu item Functions -> End Operating Round. When clicked,
- it creates a new sheet with all data copied over and then perform
- bookkeeping at the end of an OR.
- - automatically update the sheet's name to match the round label.
- The expected workflow is as follows:
- - the user went through the operating round editing values as they
- see fit.
- - at the end of the OR and before the M&A round, the user click
- Functions -> End Operating Round.
- - when the script finishes running, the user should be at a new
- sheet with round name selected.
- - the user updates the round name as they see fit.
- To install this script:
- - Open 1817 spreadsheet
- - From the menu, select Tools -> Script Editor...
- - When the editor pops up, copy and paste this script into the editor.
- - From the menu of the editor, select File -> Save
- - Close the editor and 1817 spreadsheet.
- - Re-open 1817 spreadsheet to see the effect.
- */
- // add Functions -> Next Round to the menu when the spreadsheet opens
- function onOpen(e) {
- SpreadsheetApp.getUi().createMenu("Functions")
- .addItem("End Operating Round", "EndOR")
- .addToUi();
- }
- // rename the spreadsheet by editting the round label
- function onEdit(e) {
- var sheet = SpreadsheetApp.getActiveSheet();
- sheet.setName(sheet.getRange("B21").getValue());
- }
- // creates a new sheet named "Next Round" with all data from previous
- // round copied over and reset
- function EndOR() {
- var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
- var sheet = spreadsheet.getActiveSheet().copyTo(spreadsheet);
- // update round name, the user is expected to rename this
- // to whatever they deem appropriate
- sheet.getRange("B21").setValue("Next Round");
- sheet.setName("Next Round");
- // update loan interest
- sheet.getRange("CB14").copyValuesToRange(sheet, 81, 81, 15, 15);
- // copy player end cash to begin cash
- sheet.getRange("BW4:BW7").copyValuesToRange(sheet, 4, 4, 4, 7);
- // copy company end funds to begin funds
- sheet.getRange("I21:BN21").copyValuesToRange(sheet, 9, 47, 19, 19);
- // clear company dividends
- sheet.getRange("I22:BN22").clearContent();
- // clear company expenses
- sheet.getRange("I24:BN30").clearContent();
- // clear company income
- sheet.getRange("I33:BN38").clearContent();
- // causes the new sheet to grab focus
- sheet.activate();
- sheet.setActiveSelection("B21");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement