We help IT Professionals succeed at work.
Get Started

VBA - How to create a workbook containing workbook event handlers as well as userforms.

Saqib Husain
Saqib Husain asked
Last Modified: 2016-02-10
I have a workbook which generates blank monthly timesheets for individual employees. The employee selects the name, designation, month and year and clicks a button. This copies a blank timesheet worksheet (which contains macros in the worksheet module) to a new workbook. The new workbook is ready with the worksheet event handlers for the individual.

I now need to extend the capabilities of the workbook to have workbook event handlers and also userforms. I am not clear on how to use VBA to create such workbooks.

One way I can see is to use a macro to write the macros. But this means that every individual's computer should have this feature enabled. I do not think I can go with this.

Another way could be to copy the entire workbook to a new workbook (I am not sure how I would do that) and then delete the other sheets which are not supposed to be copied over. But then the workbook module would contain all the macros related to generating the new workbook in addition to the ones needed to use the timesheet.

Can someone guide me or suggest any other method to be able to copy the macros to a new workbook?
Watch Question
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE