bouton pour afficher/cacher onglets toto, titi

setsix

XLDnaute Nouveau
[RESOLU] bouton pour afficher/cacher onglets toto, titi

Bonjour

je cherche le code VBA afficher/cacher onglets "toto", "titi", "tata"

Private Sub ToggleButton1_Click()

If Sheets(Array("toto", "tata", "titi Be")).visible = True Then
Sheets(Array("toto", "tata", "titi Be")).visible = False
ToggleButton1.Caption = "Masquer"
Exit Sub
End If
Sheets(Array("toto", "tata", "titi Be")).visible = True
ToggleButton1.Caption = "Afficher"
End Sub

j'arrive pas à trouver la bonne syntaxe pour les onglets en fait.
Est-ce qu'une âme charitable autait la solution?

merci d'avance
 
Dernière édition:

Lii

XLDnaute Impliqué
Re : bouton pour afficher/cacher onglets toto, titi

Bon soir,

autre syntaxe :
Code:
Private Sub ToggleButton1_Click()
  Dim Vu As Boolean, Vn As Byte, Cas As Byte
  ToggleButton1.Caption = IIf(ToggleButton1.Caption = "Cacher", "Afficher", "Cacher")
  Vu = IIf(ToggleButton1.Caption = "Cacher", True, False)
  Application.ScreenUpdating = False
  For Vn = 1 To Sheets.Count
    For Cas = 0 To 2 '3 feuilles
      If Sheets(Vn).Name = Array("toto", "tata", "titi Be")(Cas) Then
        Sheets(Vn).Visible = Vu
      End If
    Next
  Next
End Sub
 

Pièces jointes

  • AfficherCacherOnglets.zip
    7.1 KB · Affichages: 99

Discussions similaires

Statistiques des forums

Discussions
312 307
Messages
2 087 095
Membres
103 467
dernier inscrit
Pandiska