+ Reply to Thread
Results 1 to 3 of 3

Loop Calculate and Count

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    1

    Unhappy Loop Calculate and Count

    Hi,

    I've written a mathematical model using excel for a probability problem which requires the generation of random numbers. The idea is that I can run the model to see how long it takes for a certain condition is be satisfied.

    At the moment I have to press F9 for the RAND() function to create a new set of numbers and then manually check to see if a particular cell is greater than or equal to 5. If it is not, I then repeat the process until the conditional is met.

    It is also important for me to know how many times the random numbers were generated before my condition was met. I am currently counting the number of times I press F9 before the condition is met.

    I have tried to figure out how to automate this process using a Macro but have failed miserably. I have no experience with Visual Basic and would appreciate any help available.

    In summary, I want the following to take place in a macro:

    1. Recalculate spreadsheet (i.e. generate random numbers)
    2. Check if T24 is larger than or equal to 5
    3. If No, loop back to Step 1
    4. If Yes, stop macro and display number of iterations required

    Many Thanks

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Help with Macros - Loop Calculate and Count

    You can force a calculation using code. Why not post a workbook if you have more stuff going on?

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with Macros - Loop Calculate and Count

    This little macro should help:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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