1

I have the following code that produces a random number from 1 to 36. I would actually like to produce a random string from the names btn1 to btn36. Is there a way to do this?

Dim Low As Double
Dim High As Double
Low = 1
High = 36
R = Int((High - Low + 1) * Rnd() + Low)
Sheets("ITEMS DATA").Range("K21").Value = R
0

1 Answer 1

2

Yes. A simple string concatenation will work. Just append your random number to a "btn" string prefix like this:

Sheets("ITEMS DATA").Range("K21").Value = "btn" & R
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.