Last active
April 18, 2018 08:36
-
-
Save 9bow/128b03fe09e7811a1ae8a4edec11b0a4 to your computer and use it in GitHub Desktop.
Google Script for choosing the random name of the survey winner used in meetup.
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 onOpen(e) { | |
// Where the menu button defined | |
SpreadsheetApp.getUi().createMenu('Vuetiful').addItem('추첨~ 얍!', 'randomPick').addToUi(); | |
} | |
function randomPick() { | |
var sss = SpreadsheetApp.getActiveSpreadsheet(); | |
var ss = sss.getSheetByName('Form Responses 1'); // <- Check the sheet name | |
var range = ss.getRange(1,1,ss.getLastRow(), 3); // <- Check the last parameter: how many cells to fetch (first 3) | |
var data = range.getValues(); | |
var pickNum = 0; | |
for (;;) { | |
pickNum = Math.floor(Math.random() * data.length); | |
if (pickNum != 0) { | |
break; | |
} | |
} | |
SpreadsheetApp.getUi().alert("축하합니다~ "+ data[pickNum][1] +"님!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment