excel实现按颜色求和与计数函数
时间:2022-07-10 01:01:04
本文介绍如何按颜色求和与计数函数。
1、求相同颜色单元格个数CountColor()
FunctionCountColor(colAsRange,countrangeAsRange)AsInteger
DimicellAsRange
Application.Volatile
ForEachicellIncountrange
Ificell.Interior.ColorIndex=col.Interior.ColorIndexThen
CountColor=CountColor+1
EndIf
Nexticell
EndFunction
2、求相同颜色单元格数值和SumColor()
FunctionSumColor(colAsRange,sumrangeAsRange)AsInteger
DimicellAsRange
Application.Volatile
ForEachicellInsumrange
Ificell.Interior.ColorIndex=col.Interior.ColorIndexThen
SumColor=Application.Sum(icell)+SumColor
EndIf
Nexticell
EndFunction
具体操作过成是:
1、工具--宏--输入宏名CountColor--创建--进入vb编辑页面
2、删除所有内容--将以上代码复制后粘贴到vb编辑页面--保存为.xla(加载宏文件)
3、输入函数=CountColor(指定颜色的单元格,统计区域),
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
excel每月天数不一样,如何计算日平均销售量
![](https://img.aspxhome.com/file/2023/2/a142232_0s.png)
如何做word整页截图?word整页截图介绍
![](https://img.aspxhome.com/file/2023/2/28052_0s.jpg)
excel2007调整表格行列宽度步骤方法
![](https://img.aspxhome.com/file/2023/3/a153543_0s.jpg)
怎样在word中制作个性化简历
![](https://img.aspxhome.com/file/2023/5/20715_0s.png)
win10远程连接提示函数错误怎么办?有好的解决方法吗?
![](https://img.aspxhome.com/file/2023/8/47338_0s.jpg)
word如何设置自动添加编号
Word如何快速去除超链接 Word快速去除超链接方法
![](https://img.aspxhome.com/file/2023/7/22587_0s.jpg)
Word文档怎么插入页眉页脚
![](https://img.aspxhome.com/file/2023/3/17843_0s.jpg)
win10系统无法进入安全模式和系统界面怎么办?
![](https://img.aspxhome.com/file/2023/7/46777_0s.jpg)
excel中计算人数数量的教程
word表格自动填充技巧
excel中输入0开头的学号教程
word怎样设置超链接图解
Win10专业版windows audio服务启动不了怎么解决?
![](https://img.aspxhome.com/file/2023/0/50140_0s.jpg)
word中如何隐藏表格线
![](https://img.aspxhome.com/file/2023/3/18193_0s.jpg)
excel如何把一行内容转为多行内容
![](https://img.aspxhome.com/file/2023/6/a154176_0s.jpg)
EXCEL打印设置,怎么打印到一张纸上
excel2003自动筛选功能使用教程
如何给word添加批注?word编辑批注教程
![](https://img.aspxhome.com/file/2023/6/17656_0s.png)
Word快捷键手册:编辑移动文字图形的快捷键
![](https://img.aspxhome.com/file/2023/8/22188_0s.gif)