When,we paste the VBA codes either in 'Thisworkbook' or 'Module1'.What is the purpose for the pasting of it choose category?
Please update my knowledge for the difference of pasting,why in 'Thisworkbook' or why 'Module1'.Which should be used in normal practice for best result?
Regards
Difference between 'Modul1' and 'Thisworkbook'
-
- Lounger
- Posts: 26
- Joined: 20 Jan 2014, 11:18
- Location: nepal
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Difference between 'Modul1' and 'Thisworkbook'
All standard VBA code should be pasted into Modules (like Module 1, Module 2, etc..)
Modules are the standard storage area for general macros and automation for the workbook they are stored in.
The ThisWorkbook module is a special module that provides access to "event" handlers. See the image below that shows how to access these events. Although standard code can be pasted into the ThisWorkbook's General module, it is not common practice and certain limitations could exist when doing this. It is better to paste standard VBA into the normal modules that you inset from the Insert Menu in VBA.
Logically, the Sheet modules above ThisWorkbook give you access to the Sheet event handlers that trigger macros on ONLY that sheet based on an event linked to.
Modules are the standard storage area for general macros and automation for the workbook they are stored in.
The ThisWorkbook module is a special module that provides access to "event" handlers. See the image below that shows how to access these events. Although standard code can be pasted into the ThisWorkbook's General module, it is not common practice and certain limitations could exist when doing this. It is better to paste standard VBA into the normal modules that you inset from the Insert Menu in VBA.
Logically, the Sheet modules above ThisWorkbook give you access to the Sheet event handlers that trigger macros on ONLY that sheet based on an event linked to.
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Difference between 'Modul1' and 'Thisworkbook'
Also see this webpage by Chip Pearson: http://www.cpearson.com/excel/codemods.htm
And also this thread which is answered by Hans which leads to a thread here in Eileen's (more to do with variable scope though)!
And also this thread which is answered by Hans which leads to a thread here in Eileen's (more to do with variable scope though)!
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.