Horace
Horace

Reputation: 342

Finding code for a macro in VBA

I have an add on with lots of modules and userforms. Of course there is a lot of nesting and macro referrals in each macro. I was wondering if there is a shortcut I am not aware of to find these macros that are referenced, or if I have to go through each modules manually to find them?

In Matlab the shortcut is Ctrl+D and then the IDE would automatically open the script/function highlighted.

Upvotes: 2

Views: 92

Answers (1)

Rdster
Rdster

Reputation: 1872

When you have the cursor on the Function Call....hit Shift+F2 and it takes you to that function.

You can also hit Ctrl+Shift+F2 to cycle back to the last few cursor locations...not quite as helpful as jumping to the procedure/function header, but if you are just scrolling around following code, you can easily go back and forth.

One trick you can use is in the called function/sub comment out a line with the calling function/subs name...then while you are bouncing around in the code working through something, you can uncomment that line and Shift+F2 back to the calling function/sub.

Hope that makes sense...

Sub Main()
  ExampleSub   <----Stick your cursor in the name and hit Shift+F2 to jump to the header
End Sub

Sub ExampleSub  <----You'll jump here
'Main 'Calling Proc   <----You can use this to jump back to Main if you uncomment it

'Do Stuff
End Sub

Upvotes: 3

Related Questions