+ Reply to Thread
Results 1 to 5 of 5

Nested Loop/Check

  1. #1
    Registered User
    Join Date
    04-08-2008
    Posts
    7

    Nested Loop/Check

    So, because I hate solver and can't get it to do anything I want, can someone help me out with just creating a simple loop.

    http://www.excelforum.com/showthread.php?t=641046

    Check that thread for a sample/explanation of what I want to do.

    I was thinking all of yesterday that I was going to have to figure out how to throw all this Data into MatLAB somehow and then just create a simple nested loop to vary those weighting values. Then I realized I'm sure you can do the same in VBA, I just don't have a clue how.

    So here's what I'm thinking I want it to do:

    Vary weighting 1 from .01 to 1 in increments of .01
    .....Vary weighting 2 from .01 to 1 in increments of .01
    ..........Vary weighting 3 from .01 to 1 in increments of .01
    ...............Vary weighting 4 from .01 to 1 in increments of .01
    ....................Check the % of correct against initial % correct
    ....................If current % correct > initial % correct record weighting values 1-4
    ....................If current % correct < initial % correct, leave it
    ....................Increase weighting 4 by .01
    ...............End Loop
    ...............Increase Weighting 3 by .01
    ..........End Loop
    ..........Increase Weighting 2 by .01
    .....End loop
    .....Increase Weighting 1 by .01
    End Loop
    End



    Should be pretty simple, can someone help me out with that?
    Also, if you could link me to a tutorial on how to actual put a script into Excel properly that would be helpful, but if not I'll just search around myself

    Thanks so much!
    Last edited by DallasW; 04-10-2008 at 02:33 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello DallasW,

    Here is your example using 4 nested loops. I couldn't look at your workbook because it is Excel 2007 and I 'm running Excel 2003.
    Please Login or Register  to view this content.
    Sincrely,
    Leith Ross

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Dallas, be aware that you're going to iterate the innermost code 100,000,000 times ...

    If this is a linear programming problem, there ought to be a different (faster) way.

  4. #4
    Registered User
    Join Date
    04-08-2008
    Posts
    7
    Quote Originally Posted by shg
    Dallas, be aware that you're going to iterate the innermost code 100,000,000 times ...

    If this is a linear programming problem, there ought to be a different (faster) way.
    Ya, for some reason I forgot it was 100^4, not 10^4. We'll see what happens when I run it on two or three of the weightings, and see how long it takes...



    Any suggestions of how it could be faster? It really has nothing to do with solving an equation, because there is so much more stuff going on in the background (if you take a look at the sample file)

  5. #5
    Registered User
    Join Date
    04-08-2008
    Posts
    7
    New sample in Excel 2003 (instead of 2007) format

    Sorry!

    http://www.2shared.com/file/3127314/...c7/Sample.html

+ 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