ahmedGhnam
New Member
- Joined
- Oct 15, 2022
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I have this function that sum cells by colors from conditionally format but it return #value
i need help in this please.
i need help in this please.
VBA Code:
Function SumByColor(sumCells As Range, sumColor As Range) As Integer
Dim TotalSum As Long
Dim sumColorValue As Long
sumColorValue = sumColor.DisplayFormat.Interior.ColorIndex
TotalSum = 0
For Each rCell In sumCells
If rCell.DisplayFormat.Interior.ColorIndex = sumColorValue Then
TotalSum = TotalSum + rCell.Value
End If
Next rCell
SumByColor = TotalSum
End Function
Last edited by a moderator: