+ Reply to Thread
Results 1 to 2 of 2

randon number

Hybrid View

CobraLAD randon number 03-13-2008, 06:47 AM
dominicb Good morning CobraLAD Does... 03-13-2008, 07:01 AM
  1. #1
    Forum Contributor CobraLAD's Avatar
    Join Date
    07-23-2007
    Location
    Boksburg, South Africa
    MS-Off Ver
    Office 2019
    Posts
    346

    randon number

    I want to insert numbers 1 to 12 randomly in Range("E11:E22"), everytime I click on a commandbutton on the page, there must be no duplicate numbers

    Please help.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning CobraLAD
    Quote Originally Posted by CobraLAD
    I want to insert numbers 1 to 12 randomly in Range("E11:E22"), everytime I click on a commandbutton on the page, there must be no duplicate numbers
    Does this work OK for your needs :
    Sub test()
    Dim rand1(12)
    T = 0
    Randomize
    For n = 1 To 12
    Check1:
    rand1(n) = Int((12 * Rnd(100)) + 1)
    For F = 1 To T
    If rand1(n) = rand1(F) Then GoTo Check1:
    Next F
    T = T + 1
    Next n
    For n = 1 To 12
    Range("E" & n + 10).Value = rand1(n)
    Next n
    End Sub
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

+ 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