E列第8行以下,右边所有内容为数据
2.同列的数据求和或差
EXCEL VBA列求和
答案:1 悬赏:30 手机版
解决时间 2021-02-20 18:40
- 提问者网友:欺烟
- 2021-02-20 11:25
最佳答案
- 五星知识达人网友:春色三分
- 2021-02-20 12:48
Sub s()
c = ActiveSheet.UsedRange.Column + ActiveSheet.UsedRange.Columns.Count
r = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count
For i = 5 To c
zs = 0
fs = 0
For j = 8 To r
a = Cells(j, i)
If a <> "" Then
b = Val(a)
If b > 0 Then
zs = zs + b
Else
fs = fs + b
End If
End If
Next
If zs Or fs Then
Cells(2, i) = zs + fs
Cells(4, i) = zs
Cells(6, i) = fs
End If
Next
End Sub
c = ActiveSheet.UsedRange.Column + ActiveSheet.UsedRange.Columns.Count
r = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count
For i = 5 To c
zs = 0
fs = 0
For j = 8 To r
a = Cells(j, i)
If a <> "" Then
b = Val(a)
If b > 0 Then
zs = zs + b
Else
fs = fs + b
End If
End If
Next
If zs Or fs Then
Cells(2, i) = zs + fs
Cells(4, i) = zs
Cells(6, i) = fs
End If
Next
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯