Created
March 17, 2021 15:11
-
-
Save josephting/94ba9574440f060e0c5c30bceb9ce8e7 to your computer and use it in GitHub Desktop.
Wish Tally Row Grouping
This file contains 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
/** | |
* Set Row Group Character Event Wish History | |
*/ | |
function groupRowsCharacterEventWishHistory() { | |
groupWishHistoryRowsByName('Character Event Wish History'); | |
} | |
/** | |
* Set Row Group Permanent Wish History | |
*/ | |
function groupRowsPermanentWishHistory() { | |
groupWishHistoryRowsByName('Permanent Wish History'); | |
} | |
/** | |
* Set Row Group Weapon Event Wish History | |
*/ | |
function groupRowsWeaponEventWishHistory() { | |
groupWishHistoryRowsByName('Weapon Event Wish History'); | |
} | |
/** | |
* Set Row Group Novice Wish History | |
*/ | |
function groupRowsNoviceWishHistory() { | |
groupWishHistoryRowsByName('Novice Wish History'); | |
} | |
function groupWishHistoryRowsByName(sheetName) { | |
var sheet = findWishHistoryByName(sheetName, null); | |
if (sheet) { | |
var lastRow = sheet.getLastRow() | |
var range = sheet.getRange(2, 1, lastRow - 2) | |
clearRowGroupByName(sheetName) | |
range.shiftRowGroupDepth(1) | |
} else { | |
var message = 'Unable to connect to source'; | |
var title = 'Error'; | |
SpreadsheetApp.getActiveSpreadsheet().toast(message, title); | |
} | |
} | |
function clearRowGroupByName(sheetName) { | |
var sheet = findWishHistoryByName(sheetName, null); | |
if (sheet) { | |
while (sheet.getRowGroupDepth(2)) { | |
sheet.getRowGroup(2, 1).remove() | |
} | |
} else { | |
var message = 'Unable to connect to source'; | |
var title = 'Error'; | |
SpreadsheetApp.getActiveSpreadsheet().toast(message, title); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment