1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Long, j As Long, n As Long
If Target.Row < 10 And Target.Column < 7 And Target.Row > 2 Then
Selection.Interior.ColorIndex = 5
n = 0
For i = 3 To 9 'Boucle basé sur les lignes utilisées selon les conditions du Target
For j = 1 To 8 'Boucle basé sur les colonnes utilisées selon les conditions du Target If Cells(i, j).Interior.ColorIndex = 5 Then n = n + 1
Next j
Cells(i, 7).Value = n
n = 0
Next i
Range(Cells(3, 1), Cells(9, 6)).Interior.ColorIndex = xlNone 'Plage basée sur les conditions du Target
End If
End Sub |