Function ContaColorFC(ByRef rng As Range) Dim cella As Range Dim sFC As String ContaColorFC = 0 For Each cella In rng If cella.DisplayFormat.Interior.ColorIndex <> xlColorIndexNone Then ContaColorFC = ContaColorFC + 1 End If Next cella End Function Sub conta() ' questo il codice da avviare Dim X As Long, Ur As Long Ur = Range("A" & Rows.Count).End(xlUp).Row 'conta le righe For X = 2 To Ur 'dalla riga2 sino alla fine 'NB Controlla le colonne da 1=A sino 7=G e scrive in colonna 8=H Cells(X, 8) = ContaColorFC(Range(Cells(X, 1), Cells(X, 7)))'riga16 Next X End Sub
=MATR.SOMMA.PRODOTTO(--($B2:$G2=$L$3))
=CONTA.SE($B2:$G2;$L$3)
=ContaColorFC(B2:G2)
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) 'by Marius44 Dim FC As FormatCondition, F1, c As Range, a As Long If Not Intersect(Target, Range("L3")) Is Nothing Then For Each c In Range("B2:G9") c.Activate For Each FC In ActiveCell.FormatConditions If FC.Type = xlCellValue Then F1 = Evaluate(FC.Formula1) If ActiveCell = F1 Then a = a + 1 End If Next FC Next c MsgBox "Celle formattate = " & a End If End Sub
Sub conta() Dim X As Long, Ur As Long, cella As Range, Rng As Range, ContaColorFC As Long Ur = Range("A" & Rows.Count).End(xlUp).Row For X = 2 To Ur ContaColorFC = 0 Set Rng = Range(Cells(X, 1), Cells(X, 7)) For Each cella In Rng If cella.DisplayFormat.Interior.ColorIndex <> xlColorIndexNone Then ContaColorFC = ContaColorFC + 1 End If Next cella Cells(X, 8) = ContaColorFC Next X Set Rng = Nothing End Sub