This Workbook or Worksheets for VBA

M

Mickey

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
 
C

Chip Pearson

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.
 
M

Mickey

Hi Chip,
Thanks for the reply which makes sense and will be a great help.

Mickey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top