Multiple Modules in the same workbook?

  • Thread starter Thread starter kartune85
  • Start date Start date
K

kartune85

Is there problems with having more than one module in a workbook.

I've created a second module because I need to 'Sub DeleteModule()' for
one of them because it contains the 'Sub Auto_Open()' which I don't want
to carry over when I SaveAs.

Both modules ("module1", "B4Close") are in the same Workbook.
 
The main procedures are located in "module1" (and accessed/referenced
from a Userform) and then that module is deleted (from within the
Userform), and I need 'Private Sub Workbook_BeforeClose()' to run from
module "B4Close" when the user goes to close the workbook. But it's not
executing the code.

Any idea's on what the problem might be? My Form is so close to
completion!

Thanks,

Kartune85
 
Private Sub Workbook_BeforeClose() MUST be located in ThisWorkbook module,
not B4Close.

HTH
 
Is there a way of activating the second module and making it the modul
for 'ThisWorkbook' because I need to delete "module1" so that when
use 'SaveAs' for the workbook, 'Sub Auto_Open()' doesn't get carrie
across
 
I fear you can't do that.

Maybe you can edit (delete) part of the ThisWorkbook module
 
If you want to run BeforeClose from another procedure, why not strip the
code out from there and insert in procedure in the module, and call that new
procedure from B4Close and from the Workbook_BeforeClose?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Back
Top