ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Question (Load/Unload/Show/Hide) (https://www.excelbanter.com/excel-programming/344304-userform-question-load-unload-show-hide.html)

RPIJG[_76_]

Userform Question (Load/Unload/Show/Hide)
 

I want to be able to navigate between two userforms (seperate)

The first Userform is the chooser it basically has a combobox and when
the user selects from the Combobox the second userform loads, and the
first is unloaded. That seems to work fine. However, if the user has
chosen the wrong selection in the first userform and wants to go back
to the first, it overlaps and doesn't unload the second userform,
However, there are going to be multiple userforms accessed from that
first userform and it won't unload what isn't loaded (as it should be),
and a simple If...Then statement didn't work because I used mismatched
types. Here is kind of what I've got.

Open the workbook and Userform1 shows up.
(User selects entry from Combobox).
Userform2 loads and upon initializing Unloads Userform1.
(User clicks command button to return to Userform1)

Here either two things happen, A)Hell breaks loose, or B) not what I
want it to do.

I tried using

If Userform2.Show Then Unload Userform2 End If

But I know that isn't right because I'm mixing things and because Excel
threw a fit at me. Thanks for any help.


--
RPIJG
------------------------------------------------------------------------
RPIJG's Profile: http://www.excelforum.com/member.php...fo&userid=9285
View this thread: http://www.excelforum.com/showthread...hreadid=480698


RPIJG[_77_]

Userform Question (Load/Unload/Show/Hide)
 

Thanks for the help Bob, this didn't seem to work for me, I think
because I have so many userforms that can be accessed from Userform1

The overlap is fine with me, but is there a way I can unload all
userforms that are loaded in one fell swoop.


Can I dim all the userforms as one thing and then unload all of them
even if some aren't loaded or will that throw an error.

or is there a way I can have excel only unload the userforms that are
loaded?


--
RPIJG
------------------------------------------------------------------------
RPIJG's Profile: http://www.excelforum.com/member.php...fo&userid=9285
View this thread: http://www.excelforum.com/showthread...hreadid=480698


Bob Phillips[_6_]

Userform Question (Load/Unload/Show/Hide)
 
The userforms collection only contains forms that are loaded, not all forms
in the project, so iterating through that collection will do what you want.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RPIJG" wrote in
message ...

Thanks for the help Bob, this didn't seem to work for me, I think
because I have so many userforms that can be accessed from Userform1

The overlap is fine with me, but is there a way I can unload all
userforms that are loaded in one fell swoop.


Can I dim all the userforms as one thing and then unload all of them
even if some aren't loaded or will that throw an error.

or is there a way I can have excel only unload the userforms that are
loaded?


--
RPIJG
------------------------------------------------------------------------
RPIJG's Profile:

http://www.excelforum.com/member.php...fo&userid=9285
View this thread: http://www.excelforum.com/showthread...hreadid=480698




RPIJG[_78_]

Userform Question (Load/Unload/Show/Hide)
 

Anyone please help

--
RPIJ
-----------------------------------------------------------------------
RPIJG's Profile: http://www.excelforum.com/member.php...nfo&userid=928
View this thread: http://www.excelforum.com/showthread.php?threadid=48069


RPIJG[_81_]

Userform Question (Load/Unload/Show/Hide)
 

Anyone please help

--
RPIJ
-----------------------------------------------------------------------
RPIJG's Profile: http://www.excelforum.com/member.php...nfo&userid=928
View this thread: http://www.excelforum.com/showthread.php?threadid=48069


dok112[_56_]

Userform Question (Load/Unload/Show/Hide)
 

So, you have a userform that is a "selector" userform, and based on th
combobox selection on that form, another form will initialize, correct
If the wrong selection is made, you want to go back to the origina
userform? Why not put a commandbutton on the 2nd userform that wil
hide the current userform and re-open userform1.

sub commandbutton1_click ()

me.hide
userform1.show

end sub

or a macro that closes all userforms, and then assign that to a comman
button...and after that's done initialize the first form again w
userform1.show...

sub form_close ()
userform1.hide
userform2.hide
userform3.hide
etc...
end sub

if you're looking for something different, let me know, and I'll see i
I understand better

--
dok11
-----------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058
View this thread: http://www.excelforum.com/showthread.php?threadid=48069


RPIJG[_79_]

Userform Question (Load/Unload/Show/Hide)
 

I tried what you are saying but it wasn't working... I kept gettin
errors saying things couldn't be opened because they hadn't bee
unloaded. And secondly because not everything is shown, or loaded o
startup. So it won't hide what isn't loaded already. And I'm not sur
I want it to load all of these on startup either

--
RPIJ
-----------------------------------------------------------------------
RPIJG's Profile: http://www.excelforum.com/member.php...nfo&userid=928
View this thread: http://www.excelforum.com/showthread.php?threadid=48069


dok112[_58_]

Userform Question (Load/Unload/Show/Hide)
 

ok, so in the beginning of the command type the following...

On Error Resume Next

This will tell Excel to bypass the error of it being unloaded.

Sub test()
On Error Resume Next
UserForm1.Hide
UserForm2.Hide
UserForm3.Hide
UserForm4.Hide
End Su

--
dok11
-----------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058
View this thread: http://www.excelforum.com/showthread.php?threadid=48069


RPIJG[_80_]

Userform Question (Load/Unload/Show/Hide)
 

That should do it thanks

--
RPIJ
-----------------------------------------------------------------------
RPIJG's Profile: http://www.excelforum.com/member.php...nfo&userid=928
View this thread: http://www.excelforum.com/showthread.php?threadid=48069



All times are GMT +1. The time now is 06:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com