+ Reply to Thread
Results 1 to 10 of 10

Need help with iteration or recursion

  1. #1
    Registered User
    Join Date
    04-24-2024
    Location
    Bulgaria
    MS-Off Ver
    Office 365
    Posts
    6

    Need help with iteration or recursion

    Hi! I don't know if that is right thread,but I need help with that problem! I know that could be solved by VBA functions,but I need only solved by formulas only and(or) LAMBDA function.

    These could be done in spreadsheet calculations:

    All things start from P1,P2,P3(A9:C9 cells) values - sum in A2(that is B),then are calculated - OV,RTP,K(B2:D2 cells).The resulting K(D2 cell) helps to be determined NO1,NO2,NO3(A14:C14 cells) by O1,O2,O3(A11:C11 cells).

    These NO1,NO2,NO3 determined NP1,NP2,NP3 (A16:C16 cells) which determined NP1,NP2,NP3(A16:C16 cells).Then new K1(D5 cell) is determined.

    These values K1,NO1,NO2,NO3(D5,A14:C14 cells) determined B2(which is not in the spreadsheet).Then process repeated till B<=100,01%.

    I'm sorry for my bad english and poor explanations,but I appreciate anyone could help to solve that problem.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,238

    Re: Need help with iteration or recursion

    Welcome to the forum.

    ... determined B2(which is not in the spreadsheet).
    This seems to me to be crucial - please add it to the spreadsheet (at least what you have so far).
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-24-2024
    Location
    Bulgaria
    MS-Off Ver
    Office 365
    Posts
    6

    Smile Re: Need help with iteration or recursion

    Thanks for that

    I've added B2 and these are 2 steps of these calculations I wish could be done with formulas.I wish at the end of all operations to be output
    B value(if it's reached 100.01% or less and output these end values (Os&Ps).
    Attached Files Attached Files
    Last edited by AliGW; 04-25-2024 at 02:18 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  4. #4
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Need help with iteration or recursion

    in the sample B2 is SUM(A14:C14)

    what determines the values in a14:c14 they appear fixed

    An easy solution if they can be changed is C14=1-a14-b14

    Or another line

    in a15 =A14/(SUM($A14:$C14)) copy to the right

    B2= sum(a15:c15)

  5. #5
    Registered User
    Join Date
    04-24-2024
    Location
    Bulgaria
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Need help with iteration or recursion

    Thanks for the answer,but I may be couldn't explain what I wish to do,cause of my poor English.

    B2 is SUM(A24:C24) and not SUM(A14:C14).

    Yes A14:C14 are fixed - they are the origin values of P1:P3.

    And then A2,B2,C2,D2 are calculated.First value of B(A2 cell is calculated) and it's = 101.72% in this case.

    Further by iteration is calculated the 2nd value of B,it's B1(A5 cell) and it's = 100.21%

    And etc.

    The iterations should be stopped when B value is <=100.01%

    And I've just wish to have only these output data - that last B value and last values of P1,P2,P3(which are changed every iteration in - 14 row - 1st fixed values,19 row - changed in 1st iteration,24 row - changed in 2nd iteration and etc.)

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,238

    Re: Need help with iteration or recursion

    I wonder if this is a case where SOLVER might help?

    https://support.microsoft.com/en-gb/...b-f63e45925040

  7. #7
    Registered User
    Join Date
    04-24-2024
    Location
    Bulgaria
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Need help with iteration or recursion

    Thanks for that advice! I'll give it a try!
    Last edited by AliGW; 04-25-2024 at 06:34 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  8. #8
    Registered User
    Join Date
    04-24-2024
    Location
    Bulgaria
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Need help with iteration or recursion

    Hi,again! I couldn't solve the problem by SOLVER,but I've solved it partially by LAMBDA function.And is there a way or function in excel that execute output values in more cells - I mean that function is in one cell and output values are in any other cells?

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,843

    Re: Need help with iteration or recursion

    Here's my tutorial on setting up circular/iterative calculations in a spreadsheet: https://www.excelforum.com/tips-and-...ind-roots.html

    Your calculation appears to be a simpler successive approximations algorithm. Here's how I might set it up:

    0) In Excel Options, enable iteration.
    1) Enter starting P values in a convenient place. I chose A31:C31. Choose a convenient cell to use as a "run/don't run" toggle. I chose A27, and enter 1 in A27 to mean "reset values to initial."
    2) Repeat starting P values in adjacent columns. We anticipate an IF() function that will use the toggle to determine when to run the iteration. In D31, enter =IF($A$27=1,A31,A31) [I know it's redundant now, but we will fix it later]. Copy/paste/fill into E31:F31.
    3) Calculate O values in G31:I31. Calculate B, OV, RTP, and K in J31:M31.
    4) Calculate new O values in N31:P31, Calculate new P values in Q31:S31.
    5) Edit the formula in D31 so that the "value_if_false" argument will refer to Q31 =IF($A$27=1,A31,Q31) copy/paste/fill into E31:F31.
    6a) Enter 0 (or other value) in A27 and see if the iteration runs correctly.
    6b) Enter 1 in A27 when you need to reset the iteration loop.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  10. #10
    Registered User
    Join Date
    04-24-2024
    Location
    Bulgaria
    MS-Off Ver
    Office 365
    Posts
    6

    Thumbs up Re: Need help with iteration or recursion

    Thank you very much,MrShorty! I'll look at it!

    P.S. Solved
    Last edited by angel44e; 04-26-2024 at 04:31 AM. Reason: solved problem

+ 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. Run an entire loop instead of iteration by iteration when stepping into code?
    By Norcal1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2019, 04:20 PM
  2. [SOLVED] Simple recursion
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2016, 06:34 AM
  3. Recursion Problem
    By Losse in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2011, 05:05 PM
  4. procedure :Recursion
    By ElmerS in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2009, 01:31 PM
  5. function:Recursion
    By tido in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-25-2009, 08:18 PM
  6. [SOLVED] Abort recursion
    By Mike NG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2005, 05:05 AM
  7. [SOLVED] Recursion
    By Mike NG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-02-2005, 07:05 PM

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