永发信息网

excel表中如何进行对有颜色的单元格求和?

答案:3  悬赏:60  手机版
解决时间 2021-12-22 19:41
  • 提问者网友:蔚蓝的太阳
  • 2021-12-22 00:27
如单元格的颜色为:
A1:紫色
A2:蓝色
A3:黑色
A4:紫色
A5:黑色
A6:紫色
如何可以对表中A1:A6为紫色、蓝色、黑色的单元格的个数分别计数及求和?
最佳答案
  • 五星知识达人网友:佘樂
  • 2022-01-06 00:24
输入公式:
=sumif(A1:A6,"有颜色")

开玩笑的,这个要用vba的 里面单元格的
Interior.Color = xlNone
控制的,需要的话,HI我
全部回答
  • 1楼网友:掌灯师
  • 2022-01-06 01:09
用宏自定义一个函数就可以解决,只是不太好理解。 同时按alt和f11进入宏界面,点菜单的插入,模块,粘贴如下代码: function sumcolor(xrngcond as range, xcond as range, xsum as range) dim i as integer for i = 1 to xrngcond.rows.count if xrngcond.cells(i, 1).interior.color = xcond.interior.color then sumcolor = sumcolor + xsum.cells(i, 1) next i end function 关闭该窗口,你就有了一个新的函数sumcolor,用法如下: =sumcolor(c2:c12,c2,h2:h12) 第一个参数c2:c12为条件区域,第二个参数c2表示黄色填充,第3个参数h2:h12为待求和的区域。 同理有 =sumcolor(d2:d12,c2,h2:h12) =sumcolor(e2:e12,c2,h2:h12) ... 当然公式写为 =sumcolor(c2:c12,$c2,$h2:$h12) 就更好了,可以直接向右复制3列。 希望你能理解。
  • 2楼网友:痴妹与他
  • 2022-01-06 00:51
VBA Function Countcolor(col As Range, countrange As Range) Dim icell As Range Application.Volatile For Each icell In countrange If icell.Interior.ColorIndex = col.Interior.ColorIndex Then Countcolor = Countcolor + 1 End If Next icell End Function Function Sumcolor(col As Range, sumrange As Range) Dim icell As Range Application.Volatile For Each icell In sumrange If icell.Interior.ColorIndex = col.Interior.ColorIndex Then Sumcolor = Application.Sum(icell) + Sumcolor End If Next icell End Function
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯