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
Try using randbetween on the array.
Range("A1").Value = UserNames(Application.RandBetween(LBound(UserNames), UBound(UserNames)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With