|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub gj23w98()
- Dim oHz As Boolean
- Dim Arr(), Brr()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If sht.Name <> ActiveSheet.Name Then sht.Delete
- Next
- ' Application.DisplayAlerts = True
- ' On Error Resume Next
- Set wk = ThisWorkbook
- p = ThisWorkbook.Path & ""
- f = Dir(p & "*.xls")
- Do While f <> ""
- If f <> ThisWorkbook.Name Then
- Set ws = Workbooks.Open(p & f)
- For Each sht In ws.Worksheets
- If InStr(sht.Name, "本月数") Then
- If oHz Then
- Brr = sht.Range("c7:x43").Value
- For i = 1 To 37
- For j = 1 To 22
- ' If Brr(i, j) <> 0 Then Arr(i, j) = Arr(i, j) + Brr(i, j)
- If VBA.IsNumeric(Brr(i, j)) And VBA.IsNumeric(Arr(i, j)) Then Arr(i, j) = Arr(i, j) + Brr(i, j)
- Next
- Next
- Else
- sht.Copy after:=wk.Sheets(wk.Sheets.Count)
- Arr = sht.Range("c7:x43").Value
- oHz = True
- End If
- sht.Copy after:=wk.Sheets(wk.Sheets.Count - 1)
- ActiveSheet.Name = Replace(Split(Split(f, ".")(0), "-")(1), "A表", "")
- End If
- Next
- ws.Close False
- End If
- f = Dir
- Loop
- ' Sheets("汇总").Range("c7:x42").Value = Arr
- ' Sheets("汇总").Range("a3").Value = "编制单位:A表汇总"
- MsgBox "汇总完成!"
- Sheets("取数").Activate
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|