同学问的问题,搜索下解决了。说不定以后会用到。
excel里按Alt+F11进入VBA,在新窗口左边sheet1上右键,插入-》模块。
代码:
Function colorcount(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
colorcount = colorcount + 1
End If
Next i
End Function
vba关了,回到原来excel页面
=colorcount(要统计的颜色出现在哪个格子,统计范围)
done。