HOW TO USE SUM BY COLOR FORMULA IN EXCEL
ฝัง
- เผยแพร่เมื่อ 23 ธ.ค. 2024
- Function SumByColor(CellRange As Range, ColorCell As Range) As Double
Dim Cell As Range
Dim TargetColor As Long
Dim Total As Double
' Get the color index of the target cell
TargetColor = ColorCell.Interior.Color
' Initialize total to 0
Total = 0
' Loop through each cell in the range
For Each Cell In CellRange
If Cell.Interior.Color = TargetColor Then
If IsNumeric(Cell.Value) Then
Total = Total + Cell.Value
End If
End If
Next Cell
' Return the total sum
SumByColor = Total
End Function
NEW NEW TRICKS K LIYE FOLLOW KRE