+ Reply to Thread
Results 1 to 12 of 12

Pick a random number

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Pick a random number

    Hi,

    I need a formula that pick`s a random number from 1 - 34 and place it in A1 to G1.
    If the number in A1 will be 1, this number has been taken, and can not be used in the other cells.

    This is the first step, so I dont have any workbook to share yet.

    Hope that somebody can help me solv this.

    Best regards

    Øystein

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Pick a random number

    In a module put this UDF
    Please Login or Register  to view this content.
    Usage:
    In A1:
    Please Login or Register  to view this content.
    and drage to G1
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Pick a random number

    This is also another solution (MarcL's ideas)
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Pick a random number

    Thanks for the reply, but is there a way I can ad this code to a comandbutton?

    regards
    Øystein

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Pick a random number

    Do you mean commanbutton on worksheet or userform?
    Either you can assign the macro to any button or shape.

  6. #6
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Pick a random number

    Quote Originally Posted by YasserKhalil View Post
    In a module put this UDF
    Please Login or Register  to view this content.
    Usage:
    In A1:
    Please Login or Register  to view this content.
    and drage to G1
    Hi again,

    This only returns the value 1 in all of the cells.
    I need the numbers to vary between 1 - 34, and different everytime I do the rutine. I also want it to work from a comandbutton.

    Thanks for youre quick response and help so far

    Best regards
    Øystein

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Pick a random number

    Try
    Adjust s for starting number and e for ending number
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Pick a random number

    You can test the other solution. And also the UDF is working fine for me

  9. #9
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Pick a random number

    Quote Originally Posted by YasserKhalil View Post
    Do you mean commanbutton on worksheet or userform?
    Either you can assign the macro to any button or shape.
    Commandbutton on worksheet

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Pick a random number

    In worksheet module
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    MS 365 Subscription
    Posts
    369

    Re: Pick a random number

    Quote Originally Posted by YasserKhalil View Post
    In worksheet module
    Please Login or Register  to view this content.
    Thank yoy so mutch,

    This worked perfect

    Best regards
    Øystein

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Pick a random number

    You're welcome. Glad I can offer some help.

+ 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. pick names at random
    By ancherilvm in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 01-10-2018, 11:32 AM
  2. [SOLVED] random pick
    By Shamz41 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-07-2017, 01:06 AM
  3. Pick random number in a range but not repetitive
    By tantcu in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-08-2015, 06:05 PM
  4. uner what creteria random formulae pick up next random value?
    By roofi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-16-2014, 12:55 AM
  5. Replies: 5
    Last Post: 06-21-2013, 10:40 AM
  6. Replies: 8
    Last Post: 08-14-2009, 11:22 AM
  7. [SOLVED] Pick a Random name from a list.
    By David M Fritzke in forum Excel General
    Replies: 8
    Last Post: 06-06-2006, 10:55 AM

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