Skip to content

Instantly share code, notes, and snippets.

@palikhov
Created February 8, 2022 08:28
Show Gist options
  • Select an option

  • Save palikhov/e76fc6f7e04f012eb5046f7ecac7bde8 to your computer and use it in GitHub Desktop.

Select an option

Save palikhov/e76fc6f7e04f012eb5046f7ecac7bde8 to your computer and use it in GitHub Desktop.
Return random value from list stored in one cell in Excel
Function RandomValueFromCell(r As Range, separator As String)
Dim cell As Range
Dim i As Integer
Dim x As Double
Dim ArraySize As Integer
List = Split(r, separator)
ArraySize = UBound(List) + 1
RandomValueFromCell = List(WorksheetFunction.RandBetween(1, ArraySize) - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment