您好,欢迎来到爱go旅游网。
搜索
您的当前位置:首页Excel2007中按字体颜色求和的自定义公式

Excel2007中按字体颜色求和的自定义公式

来源:爱go旅游网


一.在Excel2007中按字体颜色求和

按字体颜色求和,经过测试(在Excel2003和2007中),非常好用,整理出来,与大家分享:

Excel 本身没有这个功能,可用以下办法实现:

打开你的工作表:点工具--宏--Visual Basic 编辑器,在左边最上一行点右键--插入--模块,然后在打开的编辑框中粘贴以下代码:

Function CountColor(col As Range, countrange As Range) As Integer

Dim icell As Range

Application.Volatile

For Each icell In countrange

If icell.Font.ColorIndex = col.Font.ColorIndex Then

CountColor = CountColor + 1

End If

Next icell

End Function

Function SumColor(col As Range, sumrange As Range) As Integer

Dim icell As Range

Application.Volatile

For Each icell In sumrange

If icell.Font.ColorIndex = col.Font.ColorIndex Then

SumColor = Application.Sum(icell) + SumColor

End If

Next icell

End Function

然后关闭,反回到工作表,点击--工具-选项--安全性--宏安全性--安全级选--低--确定

保存关闭工作表,然后再打开,这时就可以用了

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务