Bonjour,
Pourquoi faire ca via VBA ?
Vos conditions sont incomplètes et l'exemple donné ne correspond pas. En effet le coupe (400, 10) n'entre dans aucune catégorie donc on ne devrait en théorie pas le traiter et donc le laisser "vide".
Vous avez précisé 2 cas, mais pas indiqué ce que vous vouliez faire des cellules ne respectant aucun critère. Dans l'absense d'info la macro proposée ci-après ne fait rien pour ces cellules.
Sub InoTA()
Dim myVals
With ActiveSheet.Range("A2:B2")
myVals = Range(.Cells, .End(xlDown)).Value2
End With
Dim rngYellow As Range
Dim rngNothing As Range
Dim i As Long
For i = LBound(myVals, 1) To UBound(myVals, 1)
If myVals(i, 1) = 100 Or myVals(i, 1) = 350 Then
' pas de couleur
If rngNothing Is Nothing Then
Set rngNothing = ActiveSheet.Cells(i + 1, 2)
Else
Set rngNothing = Application.Union(rngNothing, ActiveSheet.Cells(i + 1, 2))
End If
ElseIf myVals(i, 2) = 0 Then
' couleur jaune
If rngYellow Is Nothing Then
Set rngYellow = ActiveSheet.Cells(i + 1, 2)
Else
Set rngYellow = Application.Union(rngYellow, ActiveSheet.Cells(i + 1, 2))
End If
End If
Next i
' coloration des cellules
rngYellow.Interior.Color = 65535
rngNothing.Interior.Color = 16777215
End Sub