Bonjour à toutes et à tous,
Voici mon problème : (je débute en vba)
Dans mon projet, je cherche à masquer/afficher à l'aide d'un bouton les lignes dont la formule en colonne A se reporte à une cellule vide (que je remplie mano en cas de besoin) dans une autre feuille du classeur.
Je suis arrivé pour le moment au code suivant :
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect
CommandButton2.Caption = IIf(CommandButton2.Caption = "Masquer", "Afficher", "Masquer")
Range("A8:A105").EntireRow.Hidden = IIf(CommandButton2.Caption = "Masquer", False, True)
End Sub
mais ceci me masque toutes les lignes nommé par Range.
Si je met ce code :
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect
CommandButton2.Caption = IIf(CommandButton2.Caption = "Masquer", "Afficher", "Masquer")
Range("A8:A105").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = IIf(CommandButton2.Caption = "Masquer", False, True)
End Sub
il me masque seulement les quelques lignes (A98:A105) qui n'ont pas de formules.
Merci pour votre aide.
Voici mon problème : (je débute en vba)
Dans mon projet, je cherche à masquer/afficher à l'aide d'un bouton les lignes dont la formule en colonne A se reporte à une cellule vide (que je remplie mano en cas de besoin) dans une autre feuille du classeur.
Je suis arrivé pour le moment au code suivant :
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect
CommandButton2.Caption = IIf(CommandButton2.Caption = "Masquer", "Afficher", "Masquer")
Range("A8:A105").EntireRow.Hidden = IIf(CommandButton2.Caption = "Masquer", False, True)
End Sub
mais ceci me masque toutes les lignes nommé par Range.
Si je met ce code :
Private Sub CommandButton2_Click()
ActiveSheet.Unprotect
CommandButton2.Caption = IIf(CommandButton2.Caption = "Masquer", "Afficher", "Masquer")
Range("A8:A105").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = IIf(CommandButton2.Caption = "Masquer", False, True)
End Sub
il me masque seulement les quelques lignes (A98:A105) qui n'ont pas de formules.
Merci pour votre aide.