Le nombre de combobox visible

Bonjour à tous,

je cherche a connaitre le nombre de combobox visible qu'il y a dans un userform.

j'ai trouvé ceci:

Dim Ctrl As Control, Cpt As Integer
For Each Ctrl In UserForm1

  If TypeOf Ctrl Is MSforms.ComboBox Then
  Cpt = Cpt + 1
End If

mais le comptage sefait sur tout les combobox même celle qui ne sont pas visible. J'ai essayé de rajouter des visible=true après MSforms.ComboBox mais bien sur ca ne fonctionne pas...

Merci pour vos retours.

Bonjour,

Une suggestion ...

Private Sub CommandButton1_Click()
Dim Ctrl As Control, Cpt As Integer

   For Each Ctrl In Controls
      If TypeOf Ctrl Is MSforms.ComboBox Then
         If Ctrl.Visible = True Then Cpt = Cpt + 1
      End If
   Next Ctrl
   MsgBox Cpt
End Sub

ric

Bonjour,

Une suggestion ...

Private Sub CommandButton1_Click()
Dim Ctrl As Control, Cpt As Integer

   For Each Ctrl In Controls
      If TypeOf Ctrl Is MSforms.ComboBox Then
         If Ctrl.Visible = True Then Cpt = Cpt + 1
      End If
   Next Ctrl
   MsgBox Cpt
End Sub

ric

Merci ça fonctionne.

Bienvenue ...

ric

Rechercher des sujets similaires à "nombre combobox visible"