Consulting

Results 1 to 8 of 8

Thread: iterate till equilibrium reached

  1. #1
    VBAX Mentor
    Joined
    Dec 2009
    Posts
    416
    Location

    iterate till equilibrium reached

    Hello

    I have the following sheet (see attachment) And I like to iterate an cell (D6) till (D21+I10=N15) or result will converge (equilibrium reached).

    A.
    Attached Files Attached Files

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Are you looking for a formula to figure out this number? Or are you looking for VBA to count D6 up by a certain number until the condition is met.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Have you tried Goal Seek?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    I think you just want to use Goal Seek.

    Make sure you have the Solver Add In installed. If you want it to be part of a macro, just record it.

  5. #5
    VBAX Mentor
    Joined
    Dec 2009
    Posts
    416
    Location
    morning

    It is possible to be solved without solver.xla? VBA?
    Attached Files Attached Files

  6. #6
    VBAX Mentor
    Joined
    Dec 2009
    Posts
    416
    Location
    I put this solution:

    [VBA]
    Option Explicit

    Private Sub Worksheet_Calculate()
    Application.EnableEvents = False
    Range("N14").Formula = "=2*PI()*(N13-N12)/(LN(((N4+2*N5)/2000)/(N4/2000))/N9+LN(((N4+2*N6)/2000)/(N4/2000))/N10+LN(((N4+2*N6+2*N7)/2000)/((N4+2*N6)/2000))/N11)"
    Range("D22").Formula = "=PI()*D21*((D4+2*D5)/1000)*D6*(D7-D8)"
    Range("I10").Formula = "=I4*(I8^4-I9^4)*I7*I5"
    Range("N14").Name = "conductivity"
    Range("D22").Name = "convection"
    Range("I10").Name = "radiation"
    Range("G19").Formula = "=conductivity-(convection+radiation)"
    On Error GoTo TheEnd

    Range("G19").GoalSeek Goal:=0, ChangingCell:=Range("D7")


    TheEnd:
    Application.EnableEvents = True
    End Sub

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
    Worksheet_Calculate
    End Sub
    [/VBA]

    What do you think?

  7. #7
    VBAX Mentor
    Joined
    Dec 2009
    Posts
    416
    Location
    I like to add extra conditions:

    [VBA]
    if (range("D4").value + 2* range("D5").value)/1000 <= 0.075 then
    Range("G10").Formula = "=I4*(I8^4-I9^4)*I7*I5*D6"
    else ..etc
    [/VBA]

    my problem is how to add condition in if statement?
    "if (range("D4").value + 2* range("D5").value)/1000 <= 0.075 then"

  8. #8
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Looks ok to me.

Posting Permissions

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