如果C5:C10背景色爲紅色,我需要從單元格B5:B10獲取SUM值。Excel - SUMIF下一個單元格顏色爲
因此,可以說C5和C8是紅色的,我需要單元格B5 + B8的SUM。
這些是我使用了模塊:http://www.exceltrick.com/how_to/sum-cells-based-on-background-color/
這不是工作:= SUMIF(C5:C10; 「=」 & GetCellColor(C5:C10)= 「=」 & GetCellColor(A1) ; B5:B10)
在此先感謝!
編輯:
GetCellColor
Function GetCellColor(xlRange As Range)
Dim indRow, indColumn As Long
Dim arResults()
Application.Volatile
If xlRange Is Nothing Then
Set xlRange = Application.ThisCell
End If
If xlRange.Count > 1 Then
ReDim arResults(1 To xlRange.Rows.Count, 1 To xlRange.Columns.Count)
For indRow = 1 To xlRange.Rows.Count
For indColumn = 1 To xlRange.Columns.Count
arResults(indRow, indColumn) = xlRange(indRow, indColumn).Interior.Color
Next
Next
GetCellColor = arResults
Else
GetCellColor = xlRange.Interior.Color
End If
End Function
你可以發佈你的UDF? – Brian
我同意。請*編輯*您的問題,**添加GetCellColor()**。 –