Erreur d'exécution '5'

Résolu/Fermé
Barnaud85 Messages postés 2 Date d'inscription lundi 21 septembre 2015 Statut Membre Dernière intervention 23 septembre 2015 - 21 sept. 2015 à 19:40
Barnaud85 Messages postés 2 Date d'inscription lundi 21 septembre 2015 Statut Membre Dernière intervention 23 septembre 2015 - 23 sept. 2015 à 12:36
Bonsoir, j'aimerais créer un programme VBA assez simple, mais une erreur lors du lancement du programme apparaît ("Erreur d'exécution '5' : Argument ou appel de procédure incorrect"). Pourriez-vous m'aider ?
Voici mon code :

ligne = ActiveCell.Row

Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=Cells(ligne, 12)>Cells(ligne, 10)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False

Merci d'avance pour votre aide.
A voir également:

1 réponse

f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 701
23 sept. 2015 à 09:56
Bonjour,

remplacez
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=Cells(ligne, 12)>Cells(ligne, 10)" 


par
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=L" & ligne & ">J" & ligne & ""
1
Barnaud85 Messages postés 2 Date d'inscription lundi 21 septembre 2015 Statut Membre Dernière intervention 23 septembre 2015
23 sept. 2015 à 12:36
C'est parfait, merci beaucoup ! :)
-1