Closing open userforms

Hello,

I am getting back to you regarding another issue.

I would like to close all the open userforms so that only the welcome userform is displayed.

I tried the following:
Dim USF As Object
For each USF in userforms
If USF.name.visible = true then USF.name.hide
Next USF
UF_Acceuil.show

But I don't understand, at the If statement I am ejected from my "for each" loop.

Best regards,

Guillaume

Configuration: iPhone / Safari 9.0

2 answers

  1. Hello

    Below is a code for a button
    1° property CmdClose
    2° name Close

    Private Sub CmdClose_Click()
    Unload Me
    End Sub
    0
    1. Hello, I tested your code, it indeed doesn't work, I don't know why. By just putting
      USF.visible
      instead of
      usf.name.visible
      it works.

      I assume Excel can't find your userforms because you renamed them differently than userform1, userform2, ...

      --
      Forum users are not clairvoyants, at least I'm not!
      0