• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Execution Flow in VBA

Hi All,

I would like to understand the concept of execution flow in VBA.
Lets say I have created a VBA file with Modules, Class Modules, Userforms and
functions in worksheet and workbooks.

On clicking the Run button , I think the below is the execution flow:-
1. Firstly the class modules
2. Then the Modules
3. Userforms gets opened and based on inputs in the user forms the flow continues.

Can anyone conclude if the flow of functions in VBA is correct.
 
you might need to tighten this one up.

I think it depends on how you structure the overall solution.
 
If you mean "Run" as in either

1. Pressing Alt+F8 and selecting a macro; or
2. a Custom Shape or Button linked to some code; or
3. You are in VBA and the cursor is within a code module

Then the subroutine you have selected will run and it will control the macro execution

If you mean Run as in via an Event, then the code is controlled by the event code for the module that is executed

If you mean Run as in Workbook_Open or Worksheet_Activate, then those events will control the flow

Remember that Excel is Object based and so a Class Module may well sit there doing nothing until either some code or an object requires its use.
 
Back
Top