aide pour une macro

pakal

XLDnaute Nouveau
Bonjour a tous et a chacun

j' ai tableau avec differents infos.

Je voudrais creer 3 boutons qui me permettent:
1)- clic sur bouton "choix a" me permet de ne voir que les lignes a ( les autres lignes sont donc masquees)
2)- clic sur bouton "choix a, b" me permet de ne voir que les lignes a et b ( les c lignes sont donc masquees)
3)- clic sur bouton "choix a, b, c" me permet de voir toutes les lignes a, b et c .
N'etant pas un specialiste de la macro, si quelqu'un peu m'apporter son aide, merci.

Je joints un fichier exel pour mieux comprendre.
 

Pièces jointes

  • bouton macro.xls
    24 KB · Affichages: 39
  • bouton macro.xls
    24 KB · Affichages: 41
  • bouton macro.xls
    24 KB · Affichages: 46
Dernière édition:

job75

XLDnaute Barbatruc
Re : aide pour une macro

Bonjour pakal, Bernard,

Il vaut mieux des OptionButtons à mon avis...

Les macros dans le code de la feuille :

Code:
Private Sub OptionButton1_Click()
Afficher 1
End Sub

Private Sub OptionButton2_Click()
Afficher 2
End Sub

Private Sub OptionButton3_Click()
Afficher 3
End Sub

Private Sub Afficher(op As Byte)
Dim plage As Range, cel As Range, affich As Range
Application.ScreenUpdating = False
Rows.Hidden = False 'affiche tout [indispensable pour End(xlUp)]
Set plage = Range("A8", Range("A65536").End(xlUp))
For Each cel In plage
  If cel = "a" Or (op > 1) * (cel = "b") Or (op = 3) * (cel = "c") Then _
    Set affich = Union(IIf(affich Is Nothing, cel, affich), cel)
Next
plage.EntireRow.Hidden = True 'masque tout
If Not affich Is Nothing Then affich.EntireRow.Hidden = False 'affiche
End Sub

Fichier joint.

A+
 

Pièces jointes

  • bouton macro(1).xls
    38.5 KB · Affichages: 26

Statistiques des forums

Discussions
312 601
Messages
2 090 150
Membres
104 411
dernier inscrit
saidokhan