Get Values from Sheet for Custom Function in Apps Script
Learn how to create a custom function in Google Sheets using Apps Script to generate random numbers based on user-defined minimum and maximum values from the sheet. This video guides you through the process of retrieving data from the active range and setting values effectively.
In a previous video, I showed you how to create a random number . So when we create a random number , you can do like rand and then time something or ran between, and we can use like this number 50 and a hundred and say, okay, there's a random number , but every time we edit our sheet it's gonna change.
The problem occurs if we want to have some data on this row, meaning this minimum and maximum in our app script . So how do we do that? How do we get data from our row that we're on this active range into our sheet?
Now we go into our cell and we can go equals, sorry, it was called generate, generate random number and it's going to be a function that we can generate a random number from these inputs, but we get a permission call set value.
But this is just recreating the ran between function and it's going to update now, not e every single time you edit the sheet.
So now that's gonna be a number . If we are on row three in the D column, that's gonna be three and we just have to get the value in e threes.
We're in column D, row three 50 to 200. Random generator. Generate random number . We get 61.
So let's go back to our app script . Go over to executions on the.
We can write row ca, colon and then add a plus sign. We can go to the minimum and in here, rate minimum colon and then a plus sign to connect those two quote, maximum end quote and a plus sign to connect those.
What did we do wrong? And we have to look at the difference and stuff and say, okay, we meant this and not that.