+ Reply to Thread
Results 1 to 4 of 4

Create unique random number after hitting command button

  1. #1
    Registered User
    Join Date
    02-09-2017
    Location
    Beernem, Belgium
    MS-Off Ver
    7
    Posts
    11

    Create unique random number after hitting command button

    Hello,

    I have this userform containing a command button. Upon hitting the command button, the code should create a unique (no diplicates) random number. This number is linked to a picture file which is stored in a certain file. This picture opens in a userform. Certain cells are shown in this picture and these can be scored (selection of option in combobox). The correct scores are given in a second excel file (Categorization.xlsx). These scores are checked against the answers chosen in the comboboxes. For the latter, I managed to write a code (see below). However, I don't know how to create unique random numbers. Also, there should be a message when all pictures are scored.
    Please find the code below.
    Thank you in advance,
    Veerle

    Please Login or Register  to view this content.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Create unique random number after hitting command button

    Have a read of link.
    http://www.exceltip.com/tips/random-...ut-repeat.html

    This returns array of specified number of element, with unique random number between min and max value supplied.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    02-09-2017
    Location
    Beernem, Belgium
    MS-Off Ver
    7
    Posts
    11

    Re: Create unique random number after hitting command button

    I tried this code, but numbers were not unique...

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Create unique random number after hitting command button

    Then try this one. Original code from http://www.ozgrid.com/VBA/RandomNumbers.htm

    Just minor change to make it return array instead of string.

    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)

Similar Threads

  1. [VBA] Create a random unique numbers generator without functions
    By alexgoaga in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-27-2017, 07:33 AM
  2. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  3. Replies: 10
    Last Post: 03-28-2014, 03:33 PM
  4. Create a command button with code with a command button
    By jakara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 01:28 PM
  5. Unique Random Number generator
    By David Obeid in forum Excel General
    Replies: 3
    Last Post: 01-28-2008, 11:27 PM
  6. [SOLVED] Create a unique random number
    By Jack in forum Excel General
    Replies: 2
    Last Post: 04-19-2006, 04:20 PM
  7. [SOLVED] command button:. how can i create a command button
    By ashley in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-29-2005, 05:05 PM

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