MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Executing a specific module

  Asked By: Rena    Date: Dec 05    Category: MS Office    Views: 1571

I have written two seperate code in three modules module 1, 2 and 3.
Everytime by pressing F5, program executes module 1. How can I execute
just module 2? Should the program care what I write in module 1 and 3
while compiling and executing module 2?



1 Answer Found

Answer #1    Answered By: Jennifer Davis     Answered On: Dec 05

Where is the cursor when you press F5?

For instance, my little test in Module1 - two subroutines "a" and "b", both with
just message boxes ... put cursor somewhere inside Sub A, press F5, message box
A; put cursor somewhere inside Sub B, press F5, message box B.

A quote from a Web page: "You can run the macros either from the Visual Basic
Editor by placing your cursor in the macro and pressing the F5 key, or from
Excel by opening the Macros dialog box (ALT+F8) choosing the macro to run and
clicking Run. It is best to run these macros from Excel so you can watch them as
they work." This is good advice.

Should Excel care about the other modules? Remember that the VBA environment is
a project environment, and all of your modules  will be part of the same project
- so Excel is interested in them all. If you want to run just one subroutine
from the project, you are making Excel depart from its "normal" mode of
operation somewhat. So you need to tell it specifically what you want it to

Didn't find what you were looking for? Find more on Executing a specific module Or get search suggestion and latest updates.