Created
April 21, 2020 14:11
-
-
Save aborruso/68547b8df77423226bf7ac0b57d9b73e to your computer and use it in GitHub Desktop.
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
/** | |
* This function by Vadorequest generates a random number in the "randomNumber" sheet. | |
* | |
* It needs to be triggered with a Google Apps Scripts trigger at https://script.google.com/home/: | |
* - Select project and add trigger | |
* - Choose which function to run: triggerAutoRefresh | |
* - Select event source: Time-driven | |
* - Select type of time based trigger: Minutes timer | |
* - Select minute interval: 10 minutes (to avoid too many requests) | |
**/ | |
// Updates cell A1 in "randomNumber" with a random number | |
function triggerAutoRefresh() { | |
SpreadsheetApp.getActive().getSheetByName('doNotDelete').getRange(1, 1).setValue(getRandomInt(1, 200)); | |
} | |
// Basic Math.random() function | |
function getRandomInt(min, max) { | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment