PDA

View Full Version : VBA



anandbw82
09-22-2009, 10:06 AM
Hi all,

can anybody suggest that what is the difference between writing VBA code in worksheet code window and module code window.

suggestions will be appreciated.

Bob Phillips
09-22-2009, 10:27 AM
The worksheet code module is to hold code that would pertain directly to that sheet, usually triggered b y some worksheet event.

The standard code module is more generic, and can be used by procedures in This Workbook, a worksheet, a form, a class, or just other procedures in standard code modules.

CreganTur
09-22-2009, 11:23 AM
There is a very big differenece, and that difference has to do with the scope of the code.

Code behind a worksheet is only available for use by that worksheet, but code placed into a module can be called from any worksheet.

Simon Lloyd
09-22-2009, 11:39 AM
Threads merged, anandbw82 please only post one thread per question.

Bob Phillips
09-22-2009, 12:04 PM
Code behind a worksheet is only available for use by that worksheet, but code placed into a module can be called from any worksheet.

Not absolutely correct, you can access a procedure in a worksheet code module if it is public in scope byh preceding with the worksheet codename.