Activate 1 UserForm from another in VBA Excel?
Solved
pijaku
Posted messages
13513
Registration date
Status
Moderator
Last intervention
-
pijaku Posted messages 13513 Registration date Status Moderator Last intervention -
pijaku Posted messages 13513 Registration date Status Moderator Last intervention -
Hello,
I am working with the "modal" properties of two userforms... Grrr!!!
The principle of what I want to achieve:
I have two UserForms. When I open the file, both userforms appear side by side. So far, no problem!
With a button on one, I want to activate the second one, and vice versa, while keeping both visible!
Of course, Hide would have been very useful, but I really want to keep both userforms visible on the screen.
Is it possible?
If so, how?
Thank you very much for your contributions and/or wise advice...
Excel 2003 (not that important as it's >97, but I still mention it...)
--
Best regards,
Franck P
I am working with the "modal" properties of two userforms... Grrr!!!
The principle of what I want to achieve:
I have two UserForms. When I open the file, both userforms appear side by side. So far, no problem!
With a button on one, I want to activate the second one, and vice versa, while keeping both visible!
Of course, Hide would have been very useful, but I really want to keep both userforms visible on the screen.
Is it possible?
If so, how?
Thank you very much for your contributions and/or wise advice...
Excel 2003 (not that important as it's >97, but I still mention it...)
--
Best regards,
Franck P
1 answer
Good evening,
I don't know if this will work for you, but you can make your userforms non-modal:
You just need to click on the userform of your choice to activate it.
This also allows you to work on your worksheet without closing your userforms.
Have a good evening
--
"To find a solution to one's problems, one must make an effort."
I don't know if this will work for you, but you can make your userforms non-modal:
UserForm1.Show 0 UserForm2.Show 0
You just need to click on the userform of your choice to activate it.
This also allows you to work on your worksheet without closing your userforms.
Have a good evening
--
"To find a solution to one's problems, one must make an effort."
Actually, I know the modal property of UserForms.
However, what I want to do is an automatic activation of UserForm2 from UserForm1 without any user intervention...
Something like:
In UserForm1:
In UserForm2:
So I tried replacing: UserForm1.Activate with: UserForm1.Show 1, userForm1.Show 0, but I still get the error message: "you cannot display a UserForm in modal mode blah blah blah..."
Well, if that’s not possible, I’ll just hide one of the two with Hide...
For me, it works if I put:
In USF1:
In USF2:
And to launch the display of both UserForms:
The problem with "Load" is that it reloads my user form into memory. However, in my Initialize procedure, I reset some of my public variables to zero. So, I'm afraid that Load will systematically reset variables that change as I use my user forms.
I eventually found an alternative solution. I'm sharing it here; it might be useful...
1- Replace the calls to the procedures: Private Sub UserForm_Activate() with: Sub UserForm1_Activate() (replace UserForm1 with the name of your UserForm)
2- Call them from the other UserForm by:
3- Place a textbox (which we will make invisible) in each user form
So the overall code would be:
In USF1:
In USF2:
Here is an example workbook attached
Could this make a useful CCM tip?
Have a great day and thank you again.
Well, yeah... let’s get to work ;)
Have a good day to you too, and you're welcome for my help, which turned out to be pretty useless ^^
I'll get to it as soon as I finish this damn binder!!!...
Yes, your help was useful because without you, I wouldn't have pushed myself harder and I would have just used hide...