Created
January 18, 2021 04:30
-
-
Save perpouh/1fb3281d53745d5aaf707307b3ac1038 to your computer and use it in GitHub Desktop.
GASでおみくじ的なもの
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
function myFunction() { | |
var id = ""; // スプレッドシートのURL | |
var spreadsheet = SpreadsheetApp.openById(id); | |
var sheet = spreadsheet.getSheetByName('シートの名前'); | |
const lastRow = sheet.getLastRow(); | |
var results=[]; | |
for(var i=2;i<=lastRow;i++){ | |
results.push(sheet.getRange(i, 1).getValue()); | |
} | |
sheet.getRange("G8").setValue(results[Math.floor(Math.random()*results.length)]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment