Results 1 to 9 of 9

Thread: Recursion Procedures in Excel VBA. Recursion technique in coding

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,458
    Rep Power
    10
    Simple recursion example 1


    Basically all we need to do to get at the typical recursion situation in VBA coding is to add a single code line in the second procedure, Sub2 , something of this form
    _ Call Sub2( ____ , ____ )
    If we take a moment to think about the arguments we pass, ( ____ , ____ ) , then we can use effectively my suggested idea of the variable for keeping track

    Each copy of Sub2 is a unique procedure with its own independent variables
    As soon as a procedure Calls another, the Calling procedure pauses. It is effectively frozen. Or in suspension. It has not Ended. It is not dead. All its variables hold there values "frozen" in them.
    The Called procedure is a separate individual copy of instructions. We see things with our eyes as the same. But they are not. Also we do not progress through the previous coding instructions. This appears the case to us in the VB Editor when we step through the coding in debug F8 mode. But we actually progress through a separate copy of the procedure.
    So every time the Call Sub2( ____ , ____ ) is encountered a new separate procedure is called into life. All variables, such as CopyNo in each copy are independent from those with the same name in other copies.
    We gave Sub2 a value for the copy number of 1 from the initial Call in the main procedure , Sub1
    Last edited by DocAElstein; 03-19-2019 at 11:15 PM.

Similar Threads

  1. Replies: 2
    Last Post: 04-10-2015, 04:18 PM
  2. add an addition cell colour to coding
    By peter renton in forum Excel Help
    Replies: 2
    Last Post: 11-20-2014, 05:16 PM

Posting Permissions

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