+ Reply to Thread
Results 1 to 4 of 4

Workaround for Excel's VBA Rnd function

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Workaround for Excel's VBA Rnd function

    I am trying to set up a bracket similar in style to the NCAA tournament 64 team bracket to determine a daily lunch champion.

    Currently, I have a model which has buttons to click for each round where each champion is decided using an if then statement with the Rnd function. The code looks something like this:

    Please Login or Register  to view this content.
    It continues with If/Then statements for the remaining 30 "match-ups" in the first round. Unfortunately, using the model this way gives the same "winner" every time you open the model and run it for the first time. Is there a way to better randomize in Excel or should I scrap this approach and do something completely different?

    Any and all help will be appreciated. As I'm sure you can tell, I am not a computer programmer by trade.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Workaround for Excel's VBA Rnd function

    You need to put a randomize statement into your code to reseed the random number generator http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    05-01-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Workaround for Excel's VBA Rnd function

    Quote Originally Posted by MrShorty View Post
    You need to put a randomize statement into your code to reseed the random number generator http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx
    Haha wow. Working perfectly now. Thanks for the help.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Workaround for Excel's VBA Rnd function

    Perfectly

    Please Login or Register  to view this content.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1