Dim cnt As Integer cnt = 0 For Each cell In target If cell.Interior.ColorIndex = 3 Then cnt = cnt + 1 Next cell countcolour = cnt End Function 在单元格中引用countcolour即可。如在F1中输入=countcolour(A1:D5)就是统计A1到D5中红色单元格的个数.注意是单元格颜色,不是字体颜色....
VBA代码:根据字体颜色对单元格进行计数: PublicFunctionCountColour(pRange1AsRange,pRange2AsRange)AsDouble'Update by ExtendofficeApplication.VolatileDimrngAsRangeForEachrngInpRange1Ifrng.Font.Color=pRange2.Font.ColorThenCountColour=CountColour+1EndIfNextEndFunction Copy 3。 然后保存此代码并返回到工作表,然后...
'Code created by Sumit Bansal from https://trumpexcel.com Function GetColorCount(CountRange As Range, CountColor As Range) Dim CountColorValue As Integer Dim TotalCount As Integer CountColorValue = CountColor.Interior.ColorIndex Set rCell = CountRange For Each rCell In CountRange If rCell....
Hey, ive got a attendance report with up to 10 weeks per person. Right now i have 2 sepertae formulas, 1 which uses cell value to determine colour (so 1=red (absent), 2=green (present) etc.) And anot...Show More excel Formulas and Functions Reply djclementsJun 2...
Dim cell As Range Dim cnt As Integer cnt = 0 For Each cell In target If cell.Interior.ColorIndex = 3 Then cnt = cnt + 1 Next cell countcolour = cnt End Function 在单元格中引用countcolour即可。如在F1中输入=countcolour(A1:D5)就是统计A1到D5中红色单元格的个数.注意是单元...
Font_coloris a reference to the cell with the sample font color. For example, to get the number of cells in B3:F24 whose values have the same font color as H3, the formula is: =CountCellsByFontColor(B3:F24, H3) Tip.If you'd like to name the functions differently, feel free to ...
Hi, Is there a way to do this but where the fill of your cell has been previously decided by conditional formatting. I have cells which are conditionally formatted a colour, depending upon the text that is in them. I then want to count how many of these new cells have the colour in ...
Excel SUMIF 函數可以幫助根據一個標準對單元格求和相關公式 跨多個工作表的 3D sum 或 sumif 本教程討論如何對 Excel 中多個連續或不連續工作表中相同範圍的單元格求和。 計算運行總數 本教程解釋了一個簡單的公式,以幫助在 Excel 中計算運行總計。 按發票編號獲取小計本教程解釋了基於 COUNTIF 和 SUMIF 函數...
For Each C In CellRange If Evaluate("Cfcolour(" & C.Address & ")") = TargetColor Then Count = Count + 1 Next C CountByColorCells = Count End Function Function CFColour(Cl As Range) As Double CFColour = Cl.DisplayFormat.Interior.Color End Function Reply Stanley says: 2023-02-06 ...
3。 然後保存此代碼並返回到工作表,然後在空白單元格中輸入此公式= CountColour(A1:D10,A2),請參見屏幕截圖: 備註:在以上公式中,A1:D10是您要使用的範圍,A2是要計數的具有特定字體顏色的單元格。 4。 輸入公式後,按Enter鍵,您將獲得帶有紅色字體顏色的單元格數。 如果要計算其他字體顏色的單元格,請根據需...