ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   This Workbook or Worksheets for VBA (https://www.excelbanter.com/excel-programming/276224-workbook-worksheets-vba.html)

Mickey[_3_]

This Workbook or Worksheets for VBA
 
Hi all,
I am learning some VBA to make more of Excel. In one book I am told to add
all the macros to 'This Workbook' whilst another book has me creating code
in separate worksheets as well as 'This Workbook'

Is there a proper way to do this as I would like to follow the correct path
to having the code run properly.

Thanks,
Mickey



Chip Pearson

This Workbook or Worksheets for VBA
 
Mickey,

Generally speaking, the ThisWorkbook module should contain only event
procedures for the workbook, and perhaps private procedures in support of
those event procedures. Similarly, the Sheet modules should contain only
event procedures for that particular sheet. If you don't know what an event
procedure is, then don't worry about it and don't put any code at all in
these modules. All other code should go in standard code modules, those you
insert from the Insert menu in VBA.




"Mickey" wrote in message
...
Hi all,
I am learning some VBA to make more of Excel. In one book I am told to

add
all the macros to 'This Workbook' whilst another book has me creating code
in separate worksheets as well as 'This Workbook'

Is there a proper way to do this as I would like to follow the correct

path
to having the code run properly.

Thanks,
Mickey





Mickey[_3_]

This Workbook or Worksheets for VBA
 
Hi Chip,
Thanks for the reply which makes sense and will be a great help.

Mickey




All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com