Hi there,
I am new to GAS and am trying to convert this bit of VBA code into GAS to apply as a custom function in sheets. The code works wonderfully in VBA but isn't working in GAS as you could probably tell from looking at it below.
My desired outcome is for the function to simulate a RANDBETWEEN with exclusions based on a defined array.
eg) I have a column that includes the numbers: 5,17,19,23,45. The function will choose a random integer between 1 and 50 but will exclude 5,17,19,23,45.
Here is the bit of VBA. Any tips would be greatly appreciated!
Function RandBetweenInt(Lowest As Long, Highest As Long, Exclude As Range) As Long
Dim R As Long
Dim C As Range
Do
R = Lowest + Int(Rnd() * (Highest + 1 - Lowest))
For Each C In Exclude
If R = C Then Exit For
Next C
Loop Until C Is Nothing
RandBetweenExcl = R
Application.Volatile
End Function