excel2007图文教程-如何统计有颜色单元格.docxVIP

  • 16
  • 0
  • 约1.53千字
  • 约 3页
  • 2019-10-23 发布于江西
  • 举报

excel2007图文教程-如何统计有颜色单元格.docx

2007EXCEL使用技巧——按指定的单元格颜色和数字颜色进行计数或求和 一、如果Excel工作表的某区域中包含不同的底纹颜色,我们可以用一个自定义函数对该区域按指定的单元格颜色进行计数或求和。方法是: ? ???? 1.按Alt+F11,打开VBA编辑器。 2.单击菜单“插入→模块”, 将插入名称为“模块1”的模块 在右侧的代码窗口中输入下列代码: 1. SumByColor,可以对区域按指定单元格的颜色求和。 Function?SumByColor(Ref_color?As?Range,?Sum_range?As?Range) Application.Volatile Dim?iCol?As?Integer Dim?rCell?As?Range iCol?=?Ref_color.Interior.ColorIndex For?Each?rCell?In?Sum_range If?iCol?=?rCell.Interior.ColorIndex?Then SumByColor?=?SumByColor?+?rCell.Value End?If Next?rCell End?Function 2. CountByColor,可以统计区域中某种颜色的个数。 Function?CountByColor(Ref_color?As?Range,?CountRange?As?Range) A

文档评论(0)

1亿VIP精品文档

相关文档