re
a VBA macro is required, here is a function proposed by Myta on the forum this morning
- to be pasted into a module (Alt+F11 to access the editor, then paste this code)
- to be used as a new function
Function NbreCellulesCouleur(Plage As Range, Couleur As Byte) As Long 'Count the number of cells of a given color in a given range 'Plage: range of cells to inspect 'Couleur: value of the color sought Application.Volatile Dim Cellule As Range For Each Cellule In Plage If Cellule.Interior.ColorIndex = Couleur And Not IsEmpty(Cellule) Then NbreCellulesCouleur = NbreCellulesCouleur + 1 End If Next Cellule End Function
How to use the formula
B9=NbreCellulesCouleur(B4:B8;3)
Note: (Excel 2003) for color codes, place a button on a sheet and paste the code
Private Sub CommandButton2_Click() dim i as long For i = 1 To 56 Range("A" & i).Value = i Range("A" & i).Interior.ColorIndex = i Next i End Sub
have a good continuation