I am trying to create a simple script activated via button to randomise a game names list. I want to enter 6 names under Rounds 1-13 and have them shuffle into certain cells. I am using the script found of the google developers website: https://developers.google.com/apps-script/reference/spreadsheet/range#randomize() - it works fine until I change .getRange to .getRangeList to select multiple names under their headers.
Googles randomizer:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var range = sheet.getRange("A1:C7");
// Randomizes the range
range.randomize();
My randomizer:
function shuffle() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Bike Bash");
const range = sheet.getRangeList(['B5:B10' ,'B12:B17' ,'B19:B24' ,'B26:B31' ,'B33:B38' ,'B40:B45' ,'B47:B52' 'B54:B59']);
// Randomizes the range
range.randomize();
}
Result: Result
The
range
you defined is not aRange
but aRangeList
, which does not has the methodrandomize
.Instead you should iterate through each
Range
.