Môžeš si vybrať bunky a definovať pomenovanú oblasť (nemusí byť spojitá), s ktorou potom môžeš normálne počítať vo vzorcoch.
Druhá možnosť je vytvoriť si pomocné funkcie, ktoré ti vrátia pole hodnôt a pole farieb, ktoré môžeš potom medzi sebou násobiť:
Function COLOR_ARRAY(aRange As Range) As Variant
Dim aColors() As Variant
Dim aIndex As Integer
Dim aCell As Range
ReDim aColors(1 To aRange.Cells.Count)
aIndex = 1
For Each aCell In aRange.Cells
aColors(aIndex) = aCell.Interior.ColorIndex
aIndex = aIndex + 1
Next
COLOR_ARRAY = aColors
End Function
Function VALUE_ARRAY(aRange As Range) As Variant
Dim aValues() As Variant
Dim aIndex As Integer
Dim aCell As Range
ReDim aValues(1 To aRange.Cells.Count)
aIndex = 1
For Each aCell In aRange.Cells
aValues(aIndex) = aCell.Value
aIndex = aIndex + 1
Next
VALUE_ARRAY = aValues
End Function
Vzorec by potom mohol napríklad pre nespojitú oblasť C1:C6;C8 vyzerať takto:=SUMPRODUCT((COLOR_ARRAY(($C$1:$C$6;$C8))=COLOR($A$1))*VALUE_ARRAY(($C$1:$C$6;$C8)))