Excel精英培训网

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

[已解决]求助,如何统计出附件中每一行不同颜色单元格的个数呢?

[复制链接]
发表于 2014-1-8 16:26 | 显示全部楼层 |阅读模式
求助,如何统计出附件中每一行不同颜色单元格的个数呢?
最佳答案
2014-1-8 16:49
  1. Function CountByColor(区域 As Range, 是否包含背景颜色 As Boolean)
  2.   Dim rng, d As Object
  3.   Set d = CreateObject("scripting.dictionary")
  4.   For Each rng In 区域
  5.     d(rng.Interior.Color) = ""
  6.   Next
  7.   If 是否包含背景颜色 = False And d.exists(16777215) Then d.Remove (16777215)
  8.   CountByColor = d.Count
  9.   Set d = Nothing
  10. End Function
复制代码
自定义函数做的,不知道可行不?

房屋信息.rar

12.4 KB, 下载次数: 9

发表于 2014-1-8 16:37 | 显示全部楼层
是统计不同颜色单元格的个数?还是统计某一区域内某种颜色单元格的个数?

另外,附件内为自定义函数,但没有代码.
回复

使用道具 举报

发表于 2014-1-8 16:49 | 显示全部楼层    本楼为最佳答案   
  1. Function CountByColor(区域 As Range, 是否包含背景颜色 As Boolean)
  2.   Dim rng, d As Object
  3.   Set d = CreateObject("scripting.dictionary")
  4.   For Each rng In 区域
  5.     d(rng.Interior.Color) = ""
  6.   Next
  7.   If 是否包含背景颜色 = False And d.exists(16777215) Then d.Remove (16777215)
  8.   CountByColor = d.Count
  9.   Set d = Nothing
  10. End Function
复制代码
自定义函数做的,不知道可行不?

房屋信息.zip

18.51 KB, 下载次数: 0

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-23 19:17 , Processed in 0.239043 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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