Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Simplification VBA

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

stagiairerm

XLDnaute Occasionnel
Y a t'il moyen de combiner cette macro ?
je suis sur qu'il y a une solution
L'idée est de masquer des lignes en fonction de plusieurs critères (variables)

merci bcp d 'avance

Rows("23:500").Select
Selection.EntireRow.Hidden = True
Range("A23:A500").Select
For Each o In Selection
If o.Value = "1" Then
o.EntireRow.Hidden = False
End If

Next
Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K518") Then
o.EntireRow.Hidden = True
End If
Next
Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K520") Then
o.EntireRow.Hidden = True
End If
Next
Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K521") Then
o.EntireRow.Hidden = True
End If
Next
Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K522") Then
o.EntireRow.Hidden = True
End If
Next
Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K523") Then
o.EntireRow.Hidden = True
End If
Next

Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K524") Then
o.EntireRow.Hidden = True
End If
Next

Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K525") Then
o.EntireRow.Hidden = True
End If
Next

Range("E23:E500").Select
For Each o In Selection
If o.Value = Range("K519") Then
o.EntireRow.Hidden = True
End If
Next
For Each o In Selection
If o.Value = Range("K519") Then
o.EntireRow.Hidden = True
End If
Next
End Sub
 
Re : Simplification VBA

Bonjour,

Peut-être ainsi pour remplacer l'ensemble des parties similaires:


Code:
For Cpt = 518 To 525
    Range("E23:E500").Select
    For Each o In Selection
        If o.Value = Range("K" & Cpt) Then
        o.EntireRow.Hidden = True
        End If
    Next o
Next Cpt

Cordialement
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
2
Affichages
528
Réponses
7
Affichages
450
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…