2013-10-10 92 views
0

如何根據在MS Excel中的背景顏色2010年我曾嘗試如何根據背景顏色總結細胞

=colorfunction(B2,F12:F192,TRUE) 

總結細胞,但它不工作

+0

你可能需要VBA這一點。公式不考慮單元格的格式(除少數考慮數字格式外)。 'colorfunction'在Excel 2010中不是一個有效的函數。 – Jerry

+0

什麼是'colorfunction'? –

+0

參見['this'](http://www.mrexcel.com/forum/excel-questions/450188-color-function-excel-2007-a.html) – 2013-10-10 07:59:07

回答

0

試用一些東西,我寫的很快。是的,它可以改進以涵蓋和處理所有可能的情況。但把它作爲你的功課。

Function clrsum(var As Range) 
    FirstRow = var.Cells(1, 1).Row 
    LastRow = var(var.Count).Row 
    col = var.Cells(1, 1).Column 

    For i = FirstRow To LastRow 
     If Cells(i, col).Interior.ColorIndex = <put some color index here> Then 
      clrsum = clrsum + Cells(i, col) 
     End If 
    Next 
    End Function 

然後用公式=一樣clrsum(A1:A10)