![]() |
Rnd (Random) in VBA
Hello. I'd like to use a Random number generator to provide a number
from 1 to 6. I would then have the result 'posted' to cell "B2". If the result is a 6, I would have another random number from 1 to 6 generated that would be 'posted' to cell "B3" (offset B2 by 1). This would continue on as long as the result comes back to be 6 for each new random number. (Does that make sense) If the results are anything but 6, then the chain would end. Result 1 = 6 (Cell B2 = 6) new Random Generated number for cell B3 (Result 2) Result 2 = 6 (Cell B3 = 6) new Random Generated number for cell B4 (Result 3) Result 3 = 6 (cell B4 = 6) " " and so on and so forth. Sorry for the repetitiveness of the data. I wanted to make sure it was clear. Thanks for any assistance. Paul |
Rnd (Random) in VBA
In this example, Rnd will result in a number between 0 and 1, so to ge
a single random digit you must multiply by 10, so to get a numbe between 1 and 6 you'll have to multiply by 7. Randomize For x = 1 To 5 MyValue = Int(Rnd * 10) Cells(x, 1).Value = MyValue Next x - Piku -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 02:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com