Chauncey Philpot
Chauncey Philpot

Reputation: 319

Excel VBA Hide all opened userforms

I have a medical userform that a clinician will be using. There are several buttons to allow them to navigate to different forms. I'm currently using a Sub that does several checks to see if the forms are visible and if so, don't be. But that's not very friendly for adaptation.

Is there a call I can make to hide all currently open visible forms. Or, cycle through all currently opened forms (eg ones in memory) Request one is obviously the lazy one for me. Request two will be sufficient as I can do the code to hide them after that.

Upvotes: 3

Views: 11005

Answers (1)

Chauncey Philpot
Chauncey Philpot

Reputation: 319

For potential google searches

This was the answer I needed. This will hide any open userforms.

Dim UForm As Object

For Each UForm In VBA.UserForms 

    If UForm.Visible = True Then
        UForm.Hide
    End If

Next

Upvotes: 8

Related Questions