+ Reply to Thread
Results 1 to 5 of 5

Random Selection With Condition- Help Needed

  1. #1
    Registered User
    Join Date
    05-24-2012
    Location
    Turkey
    MS-Off Ver
    Excel 2007
    Posts
    3

    Random Selection With Condition- Help Needed

    Hi,

    I have a problem about random selection. I have 6 columns and i need to select one number from each column, but the second selection must be bigger than the first one. For example, if my first column's(assume as column A) random choice is 14, the second's column(assume as column B) choice has to be bigger than 14.

    I wrote this formula:

    =INDEX(C3:C22;ROUND(RAND()*COUNTA(C3:C22);0))

    but i failed in implementing the condition into the formula. I attached the excel file, does anyone have any suggestions? Thanks.

    Example:
    ColumnA ColumnB ColumnC
    3 4 8
    5 13 9
    7 2 20
    12 15 22

    RND--> 5 2 -------> WRONG
    RND--> 5 13 -------> CORRECT
    Attached Files Attached Files

  2. #2
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Random Selection With Condition- Help Needed

    What if there is no number in a column bigger than the number selected before?
    If someone helped give them rep using the star button.

    If you have received a satisfactory solution please mark the thread solved. If not Fotis will come for you at night :P

  3. #3
    Registered User
    Join Date
    05-24-2012
    Location
    Turkey
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Random Selection With Condition- Help Needed

    Quote Originally Posted by darknation144 View Post
    What if there is no number in a column bigger than the number selected before?
    Yes, your approach is important and must be included in the formula for a general selection case, but this excel file will be used for lottery prediction with realized historical values. So, following number has to bigger than the previous one in all columns and due to the usage of winning numbers as an input, there won't be a problem like you mentioned in your reply.

  4. #4
    Registered User
    Join Date
    05-24-2012
    Location
    Turkey
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Random Selection With Condition- Help Needed

    Quote Originally Posted by forgo View Post
    Yes, your approach is important and must be included in the formula for a general selection case, but this excel file will be used for lottery prediction with realized historical values. So, following number has to bigger than the previous one in all columns and due to the usage of winning numbers as an input, there won't be a problem like you mentioned in your reply.
    I checked the file again and saw that there might be some cases like you pointed, skip my previous reply, my way of thinking was wrong. A suggestion, if there is a condition like you mentioned, model can make a loop and change the first number.

  5. #5
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Random Selection With Condition- Help Needed

    You'll need vba for that I know the premise basically you need a for loop but I have never touched vba someone else will have to help.

+ 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