+ Reply to Thread
Results 1 to 4 of 4

Random number generation loop for a range of cells until condition is true!

  1. #1
    Registered User
    Join Date
    08-30-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    7

    Random number generation loop for a range of cells until condition is true!

    Hey guys,

    I really tried to come up with my own solution by combining knowledge from answers to different posts, but being a total noob that I am...I just couldn't do it!

    So here is what i'm trying to do.

    1. [Do] From cell C1 to cell C30, I would like VBA to generate random results from two choices (my current excel function looks like this --> =INDEX({"G","B"},RANDBETWEEN(1,2))

    2. [Until] until cell D30 reads "Yes" (D30 contains some function based on the result of cell C1 through cell C30 and some other cells)


    so that, if a set of randomly chosen values of C1 to C30 doesn't return a "yes" in D30, it starts the whole process all over again. of course until D30 reads "Yes"

    Thanks so much in advance guys!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Random number generation loop for a range of cells until condition is true!

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-30-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Random number generation loop for a range of cells until condition is true!

    Thanks so much! I just have one quick followup question!

    Right now, the loop does stop when it sees "Yes" in D30, but the randbetween seems to run an extra loop after that....so the end result has changed due to that extra loop and D30 no longer reads "Yes".

    Maybe this has to do with the way randbetween works? is there a way to fix this so that when the loop stops, I see the actual results that stopped the loop?

  4. #4
    Registered User
    Join Date
    08-30-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Random number generation loop for a range of cells until condition is true!

    Never mind!

    I was able to stop the loop from doing an extra loop by removing

    Application.Calculation = xlCalculationAutomatic

    Thanks so much for your help mehmetcik!

+ 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. Random Number Generation
    By RalphJ in forum Excel General
    Replies: 1
    Last Post: 06-25-2010, 12:51 PM
  2. Random number generation
    By Alan Davies in forum Excel General
    Replies: 3
    Last Post: 02-27-2006, 05:40 PM
  3. [SOLVED] Random Number Generation
    By MB06 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2006, 04:45 PM
  4. [SOLVED] Generation of random numbers and sum of those with a condition
    By ramana in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-05-2005, 12:05 AM
  5. [SOLVED] Random number generation
    By Stratuser in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-15-2005, 09:06 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