如何将Excel表中相同底色的数据求和 有人可以教一下我吗 急求!!!

如题所述

按ALT+F11,调出VBA窗口,在左上角的工程窗体空白处点击右键——插入——模块,左边窗口中复制以下内容:

Function SumColor(rColor As Range, rSumRange As Range)

Application.Volatile

iCol = rColor.Interior.ColorIndex

 

   For Each rCell In rSumRange

    If rCell.Interior.ColorIndex = iCol Then

            vResult = WorksheetFunction.Sum(rCell) + vResult

    End If

   Next rCell

 

SumColor = vResultEnd Function

 

关闭VBA窗口回到excel,假设你的数据在A列,B1输入

=sumcolor(A1,A1:A15)

计算结果是A1:A15中颜色为A1单元格底色的数据之和。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-01-07

筛选→按颜色排序→自动求和(下附图)

相似回答