Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1955|回复: 1

[已解决]如何VBA进行颜色求和?

[复制链接]
发表于 2012-4-20 10:39 | 显示全部楼层 |阅读模式
一些excel工具上有这功能,就不知道VBA怎么写,谁给个代码看看。
自定义函数,按指定颜色进行求和。

如果是07/10,有颜色筛选就方便了,就是03不方便。



最佳答案
2012-4-20 10:42
  1. Function Sumcolor(col As Range, sumrange As Range)
  2.   For Each icell In sumrange
  3.       If icell.Interior.ColorIndex = col.Interior.ColorIndex Then
  4.          Sumcolor = icell+ Sumcolor
  5.       End If
  6.   Next icell
  7. End Function
复制代码
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-4-20 10:42 | 显示全部楼层    本楼为最佳答案   
  1. Function Sumcolor(col As Range, sumrange As Range)
  2.   For Each icell In sumrange
  3.       If icell.Interior.ColorIndex = col.Interior.ColorIndex Then
  4.          Sumcolor = icell+ Sumcolor
  5.       End If
  6.   Next icell
  7. End Function
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-19 21:55 , Processed in 0.171380 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表