+ Reply to Thread
Results 1 to 3 of 3

Help seeding random numbers - currently they are not random

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Help seeding random numbers - currently they are not random

    Long story short, I have a Kris Kringle spreadsheet that I wrote. It takes a list of people and randomizes who buys for who. The problem is that I have discovered it isn't random. This is the code I am using to create a random number

    Range("A1").Value = Int((1000 * Rnd()) + 1)
    This loops over and over to do its work. The trouble is that every time I run the VBA code, it generates the same random numbers in the same order. I am aware that you need to "seed" the generator to get a different starting point for the random number generator, but I can't work out how to do this. I have tried using "randomize" at the start of the VBA but that didn't work.

    Any ideas?
    My approach to providing help is to help you to help yourself. So my answers won't always solve your problem, but hopefully you can learn enough to solve the problem yourself and be more self sufficient for the experience.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953

    Re: Help seeding random numbers - currently they are not random

    x = WorksheetFunction.RandBetween(1,1000)??
    Last edited by protonLeah; 06-09-2013 at 11:02 PM.
    Ben Van Johnson

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Help seeding random numbers - currently they are not random

    See the workbook at https://www.box.com/s/ug8etrfi404n3au5md5g
    Entia non sunt multiplicanda sine necessitate

+ 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