Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting random Data created from a random formula Six Sigma Blackbelt Excel Discussion (Misc queries) 1 September 11th 08 11:03 PM
random 3 out of many Jack Sons Excel Discussion (Misc queries) 2 June 12th 08 10:19 PM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM


All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"