The following VBA code stops at Me.Show
. From my tests, it seems that Me.Show
stops all code execution, even if the code is inside the UserForm.
I think i figured it out Try doing this simple step In you form right click on the bank portion and click properties Change the "ShowModal" to False or in VBA code when you show the userform using the following code:
UserForm1.Show False
When the form is displayed with vbModal
, the code will suspend execution and wait for user interaction with the form. For example clicking a button or using a dropdown.
If you update the form property
ShowModal = False
and remove vbModal
from your code. This will allow code execution to continue when the form is displayed.
I was searching for an answer to why I was getting the following error:
Run time error '5': Invalid procedure call or argument
when running this line of code:
UserForm1.Show True
even though this line works:
UserForm1.Show False
Of course. True is not the same as vbModal! So the simple answer is to use the correct enumerations:
UserForm1.Show vbModal
UserForm1.Show vbModeless
I think I figured this out.
After Me.Show
the UserForm_Activate event fires. If there is no code in the UserForm_Activate procedure nothing will happen because VBA is waiting for Me.Hide
.
So the order of events is: Me.Show
> UserForm_Activate
> Me.Hide
Any code that I want to run must be in the UserForm_Activate procedure and must be before Me.Hide
.
The structure is very strict, but I may be able to use that structure to my advantage.
I don't really know whats going into your mind because there are a wide variety of code for what your are asking but i hope that this can help
Private Sub cmdSwitch_Click() UserForm1.Hide UserForm2.Show
End Sub