Bonjour à tous.
Je suis débutant dans le VBA et je rencontre un pb pour une macro. La ligne suivante
Selection.FormatConditions(1).ColorScaleCriteria(1).Formula = Cells(i, j) * 0.7
est surligné en jaune et le message "Erreur 438, Propriété ou méthode non gérée par cet objet" apparait.
Pourtant lorsque je passe au dessus de "Cells", le résultat est le bon (0) et lorsque je regarde ma feuille xls, la mise en forme est appliquée.
Qqun sait-il pourquoi je reçois ce message ?
merci à vous!
Adrien
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Sub Macro2()
Dim ws As Worksheet
Sheets("Coco").Select
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
For i = 1 To 14
If Cells(i, 1) = "Toto" Then
For j = 8 To 39
If Cells(i, j) <> "" Then
Range(Cells(i - 1, j), Cells(4, j)).Select
Selection.FormatConditions.AddColorScale ColorScaleType:=3
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
xlConditionValueFormula
Selection.FormatConditions(1).ColorScaleCriteria(1).Formula = Cells(i, j) * 0.7
With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
.Color = 5287936
.TintAndShade = 0
End With
Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
xlConditionValueFormula
Selection.FormatConditions(1).ColorScaleCriteria(2).Value = Cells(i, j)
With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
.Color = 65535
.TintAndShade = 0
End With
Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
xlConditionValueFormula
Selection.FormatConditions(1).ColorScaleCriteria(3).Value = Cells(i, j) * 1.3
With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
.Color = 255
.TintAndShade = 0
End With
End If
Next
End If
Next
Next ws
End Sub |
Partager