New Workbook referencing VBA from old workbook

ziadh15

New Member
Joined
May 13, 2016
Messages
33
Hello all,
My issue might be easy for some of you since I am not that experienced with Macros.

Here is a description of my project.

My initial Workbook, called MAINworkbook has one main visible sheet where user launches a userform. (20 other sheets are hidden)
Userform has 20 checkboxes where each is linked to one sheet. User will check whatever checkbox and after hitting enter;
1) A new workbook will be created Book1
2) Hidden sheets associated to every box that was checked will become visible and copied to the new workbook Book1
3) MAINworkbook will close

This was working perfectly fine.

However, I have recently did some updates and my VBA hasn't been working well.
For every hidden sheet, I have added a command button. When this button is clicked, a print preview of the page will show.

When user is running the actual VBA:
1) A new workbook will be created Book1
2) Hidden sheets associated to every box that was checked will become visible and copied to the new workbook Book1
3) Initial MAINworkbook will close
4) When user clicks on this new command button, the print preview setup will show up.
5) After closing that print preview page, the MAINworkbook will open again.

How to prevent that MAINworkbook from opening? I Guess the new Book1 is still referencing the MAINworkbook.

Would appreciate your help on this matter.
Regards
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top