|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
在一部分类 二部分类 设计分类 三个表中 合计 分别减去前面表的02 03 04 并填在 合计栏
减去.rar
(31.97 KB, 下载次数: 1)
自己撸的不对啊
Sub 减去()
For Each sh In Worksheets
For i = 4 To Range("B65536").End(xlUp).Row
Select Case sh.Name
Case Is = "一部分类"
sh.Select
With sh
If Cells(i, 2) = "总计" Then
.Cells(i, 5) = .Cells(i, 5) - [一部!O2]
.Cells(i, 6) = .Cells(i, 6) - [一部!O3]
.Cells(i, 7) = .Cells(i, 7) - [一部!O4]
End If
End With
Case Is = "二部分类"
sh.Select
With sh
If Cells(i, 2) = "总计" Then
.Cells(i, 5) = .Cells(i, 5) - [二部!O2]
.Cells(i, 6) = .Cells(i, 6) - [二部!O3]
.Cells(i, 7) = .Cells(i, 7) - [二部!O4]
End If
End With
Case Is = "设计分类"
sh.Select
With sh
If Cells(i, 2) = "总计" Then
.Cells(i, 5) = .Cells(i, 5) - [设计!O2]
.Cells(i, 6) = .Cells(i, 6) - [设计!O3]
.Cells(i, 7) = .Cells(i, 7) - [设计!O4]
End If
End With
End Select
Next
Next
End Sub
求帮助,谢谢啦
|
|