I have a couple of colleagues looking at some bad code in Excel VBA, wondering is there a limit to the number of levels in a call stack
Unless the function is tail-recursive and VBA can handle that (which it can't), you'll run into a stack overflow.
As a simple test I hacked together the following snippet:
Dim count As Integer
Sub Rec()
count = count + 1
Cells(1, 1) = count
Call Rec
End Sub
which tells us that the limit for this is 4007 iterations, at least in my version of Excel 2007 here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With