第1个回答 2009-07-31
刚回答完,又捞点分
按alt+F11打开VBE,
右击左边工程框,插入,模块
贴入以下代码
Function ystj(col As Range, countrange As Range)
Dim i As Range
Application.Volatile
For Each i In countrange
If i.Font.ColorIndex = col.Font.ColorIndex Then
ystj = ystj + 1
End If
Next
End Function
例如你标了红色字体的数据区域是第1行到第100行
在D1输入公式
=ystj(颜色,1:100)/rows(1:100) 按F9
其中颜色为想统计颜色字所在的单元格,如=ystj(A2,1:100)/rows(1:100)
如果想统计不同背景色的,将Font改为Interior。
区域1:100可为任意的excel形式(A1:C100或A:C),但最好不要选A:C这样的形式,因为每列有65535个表格,计算需很长很长时间的。查下最终的行号还是比较简单的。
统计列数本回答被提问者采纳