Macro automatique

Bonjour

j'essaie de lancer une macro qui ce lance automatiquement quand on change la valeur d'une cellule spécifique, apres avoir regarder sur différents forum j'ai fait ce code , mais il me retourne un message d'erreur "else sans if"

est ce que quelqu'un pourrait me dire d'ou vient l'erreur ?

Private Sub Worksheet_Change(ByVal Target As Range)
ElseIf Intersect(Target, [b11]) Is Nothing Then
Exit Sub
Call bpP1
ElseIf Intersect(Target, [d11]) Is Nothing Then
Exit Sub
Call bpP2
ElseIf Intersect(Target, [f11]) Is Nothing Then
Exit Sub
Call bpP3
ElseIf Intersect(Target, [h11]) Is Nothing Then
Exit Sub
Call bpP4
ElseIf Intersect(Target, [j11]) Is Nothing Then
Exit Sub
Call bpP5
ElseIf Intersect(Target, [l11]) Is Nothing Then
Exit Sub
Call bpP6
ElseIf Intersect(Target, [n11]) Is Nothing Then
Exit Sub
Call bpP7
ElseIf Intersect(Target, [p11]) Is Nothing Then
Exit Sub
Call bpP8
ElseIf Intersect(Target, [r11]) Is Nothing Then
Exit Sub
Call bpP9
ElseIf Intersect(Target, [t11]) Is Nothing Then
Exit Sub
Call bpP10
End If

End Sub

cordialement

Bonjour

On ne commence pas par un ElseIf mais par un If

A tester

Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, [b11]) Is Nothing Then
    Call bpP1
  ElseIf Not Intersect(Target, [d11]) Is Nothing Then
    Call bpP2
  ElseIf Not Intersect(Target, [f11]) Is Nothing Then
    Call bpP3
  ElseIf Not Intersect(Target, [h11]) Is Nothing Then
    Call bpP4
  ElseIf Not Intersect(Target, [j11]) Is Nothing Then
    Call bpP5
  ElseIf Not Intersect(Target, [l11]) Is Nothing Then
    Call bpP6
  ElseIf Not Intersect(Target, [n11]) Is Nothing Then
    Call bpP7
  ElseIf Not Intersect(Target, [p11]) Is Nothing Then
    Call bpP8
  ElseIf Not Intersect(Target, [r11]) Is Nothing Then
    Call bpP9
  ElseIf Not Intersect(Target, [t11]) Is Nothing Then
    Call bpP10
  End If

End Sub

merci pour ta réponse

par contre pourquoi le IF NOT au lieu du IF ?

en faite ca ne fonctionne pas , en changeant n'importe quel valeur de cellule sur ma feuille il me lance la macro


en faite j'ai trouvé la source du problème

j'ai une autre macro qui me fait la bordure de b11 ,d11... et j'ai l'impression qu'il me prend ça comme une modif de cellule , du coup il lance la macro . je crois que je vais avoir du mal a me passer de bouton ce qui ne m'arrange pas vraiment.

si quelqu'un peu me dire si j'ai raison ou pas et/ou si il y a une solution ?

cordialement

Bonjour

Sans ton fichier et quelques explications sur son fonctionnement, cela ne va pas être facile de t'aider

Rechercher des sujets similaires à "macro automatique"