Results 1 to 7 of 7

random number issue

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    random number issue

    Hi Gurus,

    I am using Rnd() function to generate random number in a loop; however, every time I run macro, the same random numbers are repeated. For clarity, I would like to post the following first 3 random numbers which repeat in the same positions.

    1. 0.705547511577606
    2. 0.533424019813538
    3. 0.579518616199493

    and so on.

    My loop looks like this:
    Sub Random()
    
    Dim R as Double, i as Integer
    
    For i = 1 to 1000
         R = Rnd() '(1st = 0.705547511577606, 2nd = 0.533424019813538, 3rd = 0.579518616199493)
         other codes ...............
    Next i
    
    End Sub
    My result should be different due to the use of random number but are in fact same. Is it a default pattern to generate random number? I was anticipating random number in every macro run with no repetitions. I appreciate your guidance.

    Thank you
    Roshan
    Last edited by Roshan.Shakya; 01-23-2021 at 08:50 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Random issue when running macro
    By Karenba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2018, 12:22 AM
  2. Random Number - Random Selection
    By stribor40 in forum Excel General
    Replies: 5
    Last Post: 05-24-2017, 02:52 PM
  3. [SOLVED] Random numbers but each number not eqully random.
    By richhhh in forum Excel General
    Replies: 11
    Last Post: 09-06-2016, 01:16 PM
  4. Replies: 5
    Last Post: 06-21-2013, 10:40 AM
  5. [SOLVED] Generate random 6-16-byte random hexadecimal number
    By jsamuelshn in forum Excel General
    Replies: 6
    Last Post: 07-20-2012, 10:38 AM
  6. Generating a Random Number of Random Numbers
    By Garrus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2010, 09:39 AM
  7. How do I find random number in list of random alpha? (Position is.
    By jlahealth-partners in forum Excel General
    Replies: 0
    Last Post: 02-08-2005, 02:06 PM

Tags for this Thread

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