Open and Close user forms

Snoreboy01

New Member
Joined
Apr 8, 2009
Messages
7
(Excel 2007, Win XP)

Hi there.
I have created a button that calls ChooseType. I choose what type, hit the Choose button and it does what it is supouse to do.
What I want to add in now, is that when I click on Choose, it inserts the value and then:
Open new user form named ChooseLevel and then Closes the current user form: ChooseType.

Here is the code I have:
Private Sub ChooseType_Click()
Sheets("CharNameHere").Activate
' TypePerson
If ChooseTypePerson Then
Call SetPerson
End If
' TypeCreature
If ChooseTypeCreature Then
Call SetCreature
End If
' TypeDivine
If ChooseTypeDivine Then
Call SetDivine
End If
' TypeTitan
If ChooseTypeTitan Then
Call SetTitan
End If
ChooseLvl.Show
Unload ChooseType

End Sub
Sub SetPerson()
Worksheets("CharNameHere").Activate
Range("B4").Value = "Person"
End Sub
Sub SetCreature()
Worksheets("CharNameHere").Activate
Range("B4").Value = "Creature"
End Sub
Sub SetDivine()
Worksheets("CharNameHere").Activate
Range("B4").Value = "Divine"
End Sub
Sub SetTitan()
Worksheets("CharNameHere").Activate
Range("B4").Value = "Titan"
End Sub


It opens ChooseLvl but then dosn't Unload ChooseType.
If I close the ChooseLvl window, then I get the error:
Run time error: '361' can not load or unload this error.

What am I doing wrong please?

Thank you.
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

westconn1

Board Regular
Joined
Feb 20, 2009
Messages
245
the code after showing the 2nd form will not run untill the second form closes
to do what you want, unload the 1st form from the activate event of the second, but as the default in excel is for the forms to be modal from the form that called it you can not do that unless you specify not modal when you show the second form
 

Watch MrExcel Video

Forum statistics

Threads
1,122,561
Messages
5,596,845
Members
414,107
Latest member
Tigretto

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
Top