Link to home
Start Free TrialLog in
Avatar of Steve_Brady
Steve_BradyFlag for United States of America

asked on

Excel VBA code location, ThisWorkbook vs. Module

Hello,

What is the difference between VBA code inserted in ThisWorkbook and a Module?  I've seen it both ways.

Thanks

 User generated image
ASKER CERTIFIED SOLUTION
Avatar of Dave
Dave
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Norie
Norie

Patrick

Does that work for subs declared Private?
imnorie,

>Does that work for subs declared Private?

By 'that' I assume you mean referencing the sub by the code pane it is in.

No, it doesn't work for 'Private' subs.

Patrick
Thought so, just wanted to check.

Sorry for not being clear.
The main point where to put code is security issue of code

If you want hide (protect) code from user - create separate .XLA file and keep code in it's modules (protected by password)

So user will be able to create his own macro but don't have access to yours
The main point of where to put code might be to put it somewhere where it will work.:)
Avatar of Steve_Brady

ASKER

multiple good answers
Steve - Thanks for the points - Patrick