Another interesting example of recursive procedures is the construction of fractals.
Fractals consist of a sequence of geometric objects, where the initial object is drawn on a large scale. Subsequently, smaller copies of this object are added to it. These copies may have the same orientation as the original object or a modified orientation.
Of course, in VBA (unlike in full Visual Basic), there are no direct tools for drawing graphics on a form. However, thanks to the Shapes object family, Excel provides abundant possibilities for creating graphics directly on a worksheet.
In the following example, we will place a geometric pattern on a worksheet using fractals.
This fractal has a simple structure:
- First, a large square is drawn.
- Then, smaller copies of this square are attached to its corners.
- This process continues until the added squares become small enough.

To view the entire picture on the worksheet, reduce the zoom level using the Zoom slider located in the lower-right corner of the Microsoft Excel window.
Let us give another example of fractal construction. In this case, the fractals are based on regular polygons. In particular, shows the result of a program that builds fractals from five-pointed stars.
This program has one notable feature: the use of a user-defined type for working with points on the plane. In this case, the user-defined type makes the code more transparent and easier to read.