Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address <> "$B$5" Then Exit Sub
Application.ScreenUpdating = False
If FilterMode Then ShowAllData
[B6:B1000] = "=IF(RAND()<0.5,-1,1)"
[B6:B1000] = [B6:B1000].Value
Target(1, 2).Select
With [C5:C1000]
.AutoFilter 1, RGB(255, 192, 0), xlFilterCellColor
[D5] = .SpecialCells(xlCellTypeVisible).Count - 1 & " cellules jaunes soit " & Format((.SpecialCells(xlCellTypeVisible).Count - 1) / 995, "0.0%")
.AutoFilter 1, RGB(142, 169, 219), xlFilterCellColor
[G5] = .SpecialCells(xlCellTypeVisible).Count - 1 & " cellules violettes soit " & Format((.SpecialCells(xlCellTypeVisible).Count - 1) / 995, "0.0%")
End With
If FilterMode Then ShowAllData
End Sub