|
楼主 |
发表于 2024-1-3 23:53
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
试增加几个语句,不知合不合理,请老师指正
Set fso = CreateObject("scripting.FileSystemObject")
Application.ScreenUpdating = False
For j = 6 To 30
ThisWorkbook.Sheets("统计表").Cells(8, j) = 0
Next j
For j = 3 To 27
ThisWorkbook.Sheets("统计表").Cells(14, j) = 0
Next j
For j = 3 To 28
ThisWorkbook.Sheets("统计表").Cells(20, j) = 0
Next j
For j = 5 To 16
For i = 6 To 13
ThisWorkbook.Sheets("呈报表").Cells(i, j) = 0
Next i
Next j
For Each f In fso.getfolder(ThisWorkbook.Path).Files
If InStr(f.Name, ThisWorkbook.Name) = 0 Then
With Workbooks.Open(f)
For j = 6 To 30
If InStr(.Sheets("统计表").Cells(7, j), "计") = 0 Then
ThisWorkbook.Sheets("统计表").Cells(8, j) = Val(ThisWorkbook.Sheets("统计表").Cells(8, j)) + Val(.Sheets("统计表").Cells(8, j))
End If
Next j
For j = 3 To 27
If InStr(.Sheets("统计表").Cells(13, j), "计") = 0 Then
ThisWorkbook.Sheets("统计表").Cells(14, j) = Val(ThisWorkbook.Sheets("统计表").Cells(14, j)) + Val(.Sheets("统计表").Cells(14, j))
End If
Next j
For j = 3 To 28
If InStr(.Sheets("统计表").Cells(19, j), "计") = 0 Then
ThisWorkbook.Sheets("统计表").Cells(20, j) = Val(ThisWorkbook.Sheets("统计表").Cells(20, j)) + Val(.Sheets("统计表").Cells(20, j))
End If
Next j
For j = 5 To 16
If InStr(.Sheets("呈报表").Cells(5, j), "计") = 0 Then
For i = 6 To 13
ThisWorkbook.Sheets("呈报表").Cells(i, j) = Val(ThisWorkbook.Sheets("呈报表").Cells(i, j)) + Val(.Sheets("呈报表").Cells(i, j))
Next i
End If
Next j
.Close False
End With
End If
Next f
Application.ScreenUpdating = True
End Sub
|
|