PDA

View Full Version : Calling multiple sub procedures fails after 1st Sub!



itipu
07-26-2007, 05:46 AM
Hi All!!!

I have something like this:
Sub Mike()
'creates worksheet A
End Sub

Sub John()
'creates worksheet B
End Sub

Sub Mark()
'created worksheet C
End Sub


I also have:

'Maint Report:
Private Sub CommandButton1_Click()
Mike
John
Mark
UserForm1.Show
End Sub

UserForm1 will ask user to select sheets and will perform some operations on the sheets...

However script jumps to UserForm1.Show right after it generates worksheet A or calls proceedure Mike...

Why does it not call on John and Mark?

I can manually generate all worksheets, so I can manually run Mike, John & Mark and they all work!

Thanks a lot

Mike

Bob Phillips
07-26-2007, 05:49 AM
I think you need to post the actual workbook here, something is happening in the coe there methinks.

itipu
07-26-2007, 05:58 AM
You won't be able to run any of the subs as they are internal AD and other databases... but you could see the code at least!

Thanks a lot

Mike

rory
07-26-2007, 06:22 AM
Hi Mike,
Try removing the Unload frmExtract line from the AD routine. Trying to unload the form that the code is in doesn't make a lot of sense. Hiding it is better.
Regards,
Rory

Charlize
07-26-2007, 06:26 AM
Try using option explicit and dim all your variables (after that the code continues) (When I removed the reference to sap ..., the code runs without dimming all the variables (personnally, I declare all my variables to make sure that I know what I'm doing)). Although not necessary I tend to use the Call keyword to make it more obvious that you call a procedure.

itipu
07-26-2007, 06:29 AM
Removing Unload fixed the problem!

Cheers to you all!

Mike