How can i unload userform1 and show userform2 correctly?

MisterExcellent

New Member
Joined
Apr 21, 2011
Messages
46
Hello all!

How can i show then unload userform1 and show userform2 correctly?

The first userform should be shown, if the listbox is filled.
If the listbox is filled and the userform1 is shown, i can unload this userform and show userform2 with a commandbutton.
If there are no data (the listbox is empty) it should unload and show the second userform.

My solution doesn't work:
Code:
If ListBox1.ListCount = 0 Then UserForm1.Hide [COLOR=DarkOrange]And Userform2.Show[/COLOR]
    Application.OnTime Now + TimeValue("00:00:02"), "ThisWorkbook.Close"
Else
    Me.Show
End If
End Sub
I look forward to your approach..
Bye for now..

Version: Excel2003
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try

Code:
If ListBox1.ListCount = 0 Then 
    UserForm1.Hide 
    Userform2.Show
    Application.OnTime Now + TimeValue("00:00:02"), "ThisWorkbook.Close"
Else
    Me.Show
End If
End Sub
 
Upvote 0
how should i open the workbook if i want to see the firstly (filled) userform1?

How would you open the workbook to show firstly the userform1 and if its empty userform2?

My solution doesn't work:

Code:
Option Explicit
 Private Sub Workbook_Open()
 Application.Visible = False
 [COLOR=Orange]UserForm1.Show[/COLOR]
 End Sub
with this code is wrongly userform2 shown at first.

And is there a way to unload the "empty" userform1 without runtime error 91?
Code:
If ListBox1.ListCount = 0 And ListBox2.ListCount = 0 And ListBox3.ListCount = 0 Then
[COLOR=Orange]    Unload Me[/COLOR]
    UserForm3.Show
    Application.OnTime Now + TimeValue("00:00:02"), "This Workbook.Close"
Else
    Me.Show
End If
End Sub
 
Upvote 0
About you first question i am not sure. Maybe try to seach the web.

The second problem, remeber that "Me" is the active userform, so it might be better to write the userform name

Code:
unload UserForm1
 
Upvote 0
About you first question i am not sure. Maybe try to seach the web.

The second problem, remeber that "Me" is the active userform, so it might be better to write the userform name

Code:
unload UserForm1

Thank you.
I searched the web but nothing usefull found.
I'm getting with unload userform1 (also unload me) an runtime error 91 to userform1.show in the workbook_open.

there is a third userform which i am starting.
this could be the problem why re91 appear.

how can i start the third userform in workbook_open?

i have to use "with"

Code:
Option Explicit  
Private Sub Workbook_Open()  
Application.Visible = False  
UserForm1.Show
Userform3.Show
 End Sub
 
Upvote 0
Hi. I tohught a little about tour problem. I do not know why you are using so many userforms, but have you considert to possibility of using just one userform and then hide/unhide items on that userfrom?. Remerber you can also use multipage userfroms and then hide unhide different pages. I think this will make you life alot easier.
 
Upvote 0
Hi. I tohught a little about tour problem. I do not know why you are using so many userforms, but have you considert to possibility of using just one userform and then hide/unhide items on that userfrom?. Remerber you can also use multipage userfroms and then hide unhide different pages. I think this will make you life alot easier.

Hi.
Thank you for your support :)

I'm using different 3 userforms with different functionalities and display formats.

I have to show and unload all this three userforms separately.
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top