2个回答
2014-06-19
展开全部
对所有 非白 填充颜色单元格求和:
Function mySum(Area As Range)
Dim i&
With Area
搏模伏 For i = 1 To .Count
If .Cells(i).Interior.Color <> 基携&HFFFFFF And IsNumeric(.Cells(i)) Then 码橡_
mySum = mySum + .Cells(i)
Next i
End With
End Function
展开全部
你卜蠢孝只要选择单元格区域,它会给档姿你统计出来。
Sub 颜色单元格求和()
Dim rg As Range
Dim r0, c0 As Long '初始型稿行列
Dim rc, cc As Long '区域数行列数统计
Dim r, c As Long '行列数循环
Dim s As Integer
DoEvents
Set rg = Application.InputBox("请用鼠标选择数据单元格或者键入单元格地址", "提示", Type:=8)
rg.Select
rc = Selection.Rows.Count
cc = Selection.Columns.Count
r0 = Selection.Row
c0 = Selection.Column
For r = r0 To r0 + rc - 1
For c = c0 To c0 + cc - 1
If Cells(r, c).Interior.ColorIndex <> -4142 Then
s = s + Cells(r, c)
End If
Next c
Next r
MsgBox "你选择的区域有背景颜色的单元格的和为: " & s, vbInformation
End Sub
Sub 颜色单元格求和()
Dim rg As Range
Dim r0, c0 As Long '初始型稿行列
Dim rc, cc As Long '区域数行列数统计
Dim r, c As Long '行列数循环
Dim s As Integer
DoEvents
Set rg = Application.InputBox("请用鼠标选择数据单元格或者键入单元格地址", "提示", Type:=8)
rg.Select
rc = Selection.Rows.Count
cc = Selection.Columns.Count
r0 = Selection.Row
c0 = Selection.Column
For r = r0 To r0 + rc - 1
For c = c0 To c0 + cc - 1
If Cells(r, c).Interior.ColorIndex <> -4142 Then
s = s + Cells(r, c)
End If
Next c
Next r
MsgBox "你选择的区域有背景颜色的单元格的和为: " & s, vbInformation
End Sub
更多追问追答
追问
非常感谢你的帮助,可是这个编程我应该怎么运用到表格里?
追答
你只要把程序复制到宏编辑器里面然后运行下就可以了。步骤看附件。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询