电脑教程
位置:首页>> 电脑教程>> office教程>> excel实现按颜色求和与计数函数

excel实现按颜色求和与计数函数

  发布时间:2022-07-10 01:01:04 

标签:函数,单元格,求和,颜色,Excel函数

本文介绍如何按颜色求和与计数函数。

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(指定颜色的单元格,统计区域),

0
投稿

猜你喜欢

手机版 电脑教程 asp之家 www.aspxhome.com