Macro mal écrite

F

Fabien

Guest
Bonjour

Je tente décrire une macro qui affiche ou masque des lignes en fonction de la valeur d'une cellule, sur une feuille pas sur un bouton

Private Sub Affichage_Zone_Utile()

If Range("E4").Value = "A COMPLETER ABSOLUMENT" Then
Rows("5:65536").Hidden = True
If Range("E4").Value = "DEPARTEMENTALE 2,DEPARTEMENTALE 1,NATIONALE 3,NATIONALE 2" Then
Rows("5:63").Hidden = False
Rows("64:65536").Hidden = True
If Range("E4").Value = "NATIONALE 1" Then
Rows("5:63,205:65536").Hidden = True
Rows("64:204").Hidden = False

End Sub

Quelqu'un voit il les erreurs

Merci
 
F

Fabien

Guest
J'ai apporté les corrections mais ne fonctionne tjs pas

Private Sub Affichage_Zone_Utile()

ElseIf Range("E4").Value = "A COMPLETER ABSOLUMENT" Then
Rows("5:65536").Hidden = True
ElseIf Range("E4").Value = "DEPARTEMENTALE 2,DEPARTEMENTALE 1,NATIONALE 3,NATIONALE 2" Then
Rows("5:63").Hidden = False
Rows("64:65536").Hidden = True
ElseIf Range("E4").Value = "NATIONALE 1" Then
Rows("5:63,205:65536").Hidden = True
Rows("64:204").Hidden = False
End If
End Sub

Merci
 
C

CBernardT

Guest
Bonsoir Fabien et Eric

Comme un petit schéma vaut mieux qu'un long discours, le fichier joint répond, je pense à ta question.

J'ai mis en "E4" une liste de validation pour tester les différentes possibilités. Pour l'enlever faire effacer tout.

Cordialement

CBernardT
 

Pièces jointes

  • Afficherzones.zip
    9.3 KB · Affichages: 19
R

Raja

Guest
Salut,
Je suis un nouveau pour ce forum. Essaies le code suivant :

Private Sub Affichage_Zone_Utile()
Rows.Hidden = False
Select Case Range("E4").Value
Case "A COMPLETER ABSOLUMENT"
Case "DEPARTEMENTALE 1", "DEPARTEMENTALE 2", "NATIONALE 2", "NATIONALE 3"
Rows("64:65536").Hidden = True
Case "NATIONALE 1"
Rows("5:63").Hidden = True
Rows("205:65536").Hidden = True
End Select
End Sub

Ce n'est peut être pas le meilleur. Mais ça marche.
a+
 
R

Raja

Guest
Excuse moi j'ai oublié une ligne.

Private Sub Affichage_Zone_Utile()
Rows.Hidden = False
Select Case Range("E4").Value
Case "A COMPLETER ABSOLUMENT"
Rows("5:65536").Hidden = True
Case "DEPARTEMENTALE 1", "DEPARTEMENTALE 2", "NATIONALE 2", "NATIONALE 3"
Rows("64:65536").Hidden = True
Case "NATIONALE 1"
Rows("5:63").Hidden = True
Rows("205:65536").Hidden = True
End Select
End Sub
 

Discussions similaires

Réponses
2
Affichages
560

Statistiques des forums

Discussions
312 971
Messages
2 094 046
Membres
105 927
dernier inscrit
rayade baali