How do I make the following code input either "Jack" or "John" randomly in cell A1? Currently, the result is always "2":
Sub RandomNames ()
Dim UserNames(1 To 2) As String
UserNames(1) = "Jack"
UserNames(2) = "John"
Range("A1").Value = Application.WorksheetFunction.RandBetween(LBound(UserNames), UBound(UserNames))
End Sub
=CHOOSE(RANDBETWEEN(1,2),"Jack","John")Currently, the result is always "2"is a little misleading as to your problem, as the code will return both1and2.