Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   This is a script to help with automatically roll over at the end of
  3.   an operating round. The script comes in two parts:
  4.  
  5.   - add a new menu item Functions -> End Operating Round. When clicked,
  6.     it creates a new sheet with all data copied over and then perform
  7.     bookkeeping at the end of an OR.
  8.   - automatically update the sheet's name to match the round label.
  9.  
  10.   The expected workflow is as follows:
  11.  
  12.   - the user went through the operating round editing values as they
  13.     see fit.
  14.   - at the end of the OR and before the M&A round, the user click
  15.     Functions -> End Operating Round.
  16.   - when the script finishes running, the user should be at a new
  17.     sheet with round name selected.
  18.   - the user updates the round name as they see fit.
  19.    
  20.   To install this script:
  21.  
  22.   - Open 1817 spreadsheet
  23.   - From the menu, select Tools -> Script Editor...
  24.   - When the editor pops up, copy and paste this script into the editor.
  25.   - From the menu of the editor, select File -> Save
  26.   - Close the editor and 1817 spreadsheet.
  27.   - Re-open 1817 spreadsheet to see the effect.
  28. */
  29.  
  30. // add Functions -> Next Round to the menu when the spreadsheet opens
  31. function onOpen(e) {
  32.   SpreadsheetApp.getUi().createMenu("Functions")
  33.     .addItem("End Operating Round", "EndOR")
  34.     .addToUi();
  35. }
  36.  
  37. // rename the spreadsheet by editting the round label
  38. function onEdit(e) {
  39.   var sheet = SpreadsheetApp.getActiveSheet();
  40.   sheet.setName(sheet.getRange("B21").getValue());
  41. }
  42.  
  43. // creates a new sheet named "Next Round" with all data from previous
  44. // round copied over and reset
  45. function EndOR() {
  46.   var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  47.   var sheet = spreadsheet.getActiveSheet().copyTo(spreadsheet);
  48.  
  49.   // update round name, the user is expected to rename this
  50.   // to whatever they deem appropriate
  51.   sheet.getRange("B21").setValue("Next Round");
  52.   sheet.setName("Next Round");
  53.  
  54.   // update loan interest
  55.   sheet.getRange("CB14").copyValuesToRange(sheet, 81, 81, 15, 15);
  56.  
  57.   // copy player end cash to begin cash
  58.   sheet.getRange("BW4:BW7").copyValuesToRange(sheet, 4, 4, 4, 7);
  59.  
  60.   // copy company end funds to begin funds
  61.   sheet.getRange("I21:BN21").copyValuesToRange(sheet, 9, 47, 19, 19);
  62.  
  63.   // clear company dividends  
  64.   sheet.getRange("I22:BN22").clearContent();
  65.   // clear company expenses
  66.   sheet.getRange("I24:BN30").clearContent();
  67.   // clear company income
  68.   sheet.getRange("I33:BN38").clearContent();
  69.  
  70.   // causes the new sheet to grab focus
  71.   sheet.activate();
  72.   sheet.setActiveSelection("B21");
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement