Skip to content

Instantly share code, notes, and snippets.

@josephting
Created March 17, 2021 15:11
Show Gist options
  • Save josephting/94ba9574440f060e0c5c30bceb9ce8e7 to your computer and use it in GitHub Desktop.
Save josephting/94ba9574440f060e0c5c30bceb9ce8e7 to your computer and use it in GitHub Desktop.
Wish Tally Row Grouping
/**
* 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