Say I have a big primary routine, that does many things and calls various other programs.
When debugging, I step through my main program with F8 so I can see line by line what's happening.
However, when I do this, any routines I call from that main sub also get stepped through. Instead of scrolling to that called routine's End Sub
, and placing a Break, is there a way to have VBA just run that routine, but then stop when I get back to my main program?
Currently, I have two ways to do this. Add a break in the line after I call a sub, in the MAIN routine - or - I add a break in that called routine's End Sub
line.
For example,
Sub main_program()
Dim rng As Range
Set rng = Range("A1:Z1000")
do_things rng
Dim cel As Range
For Each cel In rng.SpecialCells(xlCellTypeBlanks)
Debug.Print cel.Offset(1, 0).Value
Next cel
End Sub
Sub do_things(rng As Range)
Dim cel As Range
For Each cel In rng
If cel.Value <> "something" Then
cel.Font.Bold = True
End If
Next cel
End Sub
So when going through my main program line by line, I'd like to be able to run do_things
without having to put a break on For Each cel in rng...
, or the End Sub
.
I'd guess one solution is to have VBA just automatically break
when it hits an End Sub
line, or something. I'm open to ideas, I have searched around and can't find anything really other than the current solutions I mentioned above.
(Sorry if the title is a little clunky, I couldn't really think of a better way to phrase it - feel free to edit).