Unload all userforms

rinnue

Board Regular
Joined
Feb 28, 2003
Messages
142
What I would like to do is have a module that when run will unload all userforms and then show my Home userform. I cannot figure how to do it.

I would like to create a generic module so I do not have to know which userform is open at the time. Just unload all my userforms and show my begining userform again.

Something like:

Private Sub CloseAll()

'unload all forms
Home.Show

End Sub

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Forms requires VB. It's not supported by VBA. Use

Code:
Sub testIt2()
    Dim i As Long, Str As String
    For i = VBA.UserForms.Count - 1 To 0 Step -1
        Str = Str & VBA.UserForms(i).Name & vbNewLine
        Unload VBA.UserForms(i)
        Next i
    MsgBox Str & "unloaded"
    End Sub
Thank you for such Help... imagine after 13 month of posting this Code, someone else benefited of using it.
Appreciate those people who have the knowledge and willingly supporting others.
 
Upvote 0

Forum statistics

Threads
1,226,105
Messages
6,188,966
Members
453,515
Latest member
maccannix

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