Consulting

Results 1 to 8 of 8

Thread: Continuous Looping, help!

  1. #1

    Continuous Looping, help!

    Hi, Can a guru help? The loop keeps on going even though the three cells have become 0. What did I do wrong?

    Do

    Range(hello1).GoalSeek Goal:=0, ChangingCell:=Range("A123")
    Range(hello2).GoalSeek Goal:=0, ChangingCell:=Range("A124")
    Range(hello3).GoalSeek Goal:=0, ChangingCell:=Range("A125")

    Loop Until Range(hello1).Value = 0 And Range(hello2).Value = 0 And Range(hello3).Value = 0

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Well that really depends on the formulae in the cells!
    Or conside using Solver which allows you to control the number of iterations and or the time allowed.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Also are you sure they're = 0.000000000000000000.... ?

    Maybe

    [VBA]
    Abs(Range(hello1).Value) <= 0.000001
    [/VBA]

    Paul

  4. #4
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    Also consider whether the 3 hello ranges are independent of each other and the other 2 change ranges (other than selected for each goal seek). If not then you can (and will) chase your tail (as you are trying to solve a set of simultaneous equations).
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  5. #5
    Gentlemen,

    Thanks for the reply. What can I do about it?

    Do you think another loop method may work?

  6. #6
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    To answer both @P45cal's questions and mine I think we need to see a sample workbook before suggesting an alternate approach.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  7. #7
    Oh, I used Excel's built-in solver, and it's working the way I want it to be.

  8. #8
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    Good to hear. The solver gives you a lot more control of the process and you can use the constraints to reduce the chance of divergence but if your initial guess is too far out it's still not perfect.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •