开发者

Combining numbers and strings to generate random output

开发者 https://www.devze.com 2023-02-25 02:47 出处:网络
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?

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 Hig开发者_StackOverflow社区h As Double
Low = 1
High = 36
R = Int((High - Low + 1) * Rnd() + Low)
Sheets("ITEMS DATA").Range("K21").Value = R


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
0

精彩评论

暂无评论...
验证码 换一张
取 消