WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 520 reviews for our classroom and online training
Writing recursive programs in VBA
Part one of a four-part series of blogs

In certain cases in VBA (displaying the contents of folders, listing hierarchical data) writing a program which calls itself is by far the easiest way to go - this blog gives worked examples of 3 such recursive programs.

  1. Recursive Programming (this blog)
  2. Using Recursion to Display the Contents of a Folder
  3. Using Recursion to Show Hierarchical Breadcrumbs
  4. Using Recursion to Solve Factorials

This blog is part of our Excel VBA tutorial series of blogs (consider also booking on one of our Visual Basic for Applications courses).

Posted by Andy Brown on 20 February 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Recursive Programming

The dictionary definition of Recursion says it all:

Recursion (n.) - see under "Recursion"

And if you didn't get (or like) that joke, here's a real definition: recursive programming is when you write a program which calls itself. 

In practice there are few occasions when you'll actually use recursion - but when you do need it, it's nearly indispensable! 

The examples this blog will show are:

Example Notes
Folder contents Recursively looping over folders and subfolders
Creating breadcrumbs Creating menu breadcrumbs for hierarchical data
Calculating a factorial Calculating the factorial of a number

Of these, it would be much harder to write the first two examples without using recursion.


This blog has 0 threads Add post