|
楼主 |
发表于 2014-3-25 21:33
|
显示全部楼层
dsmch 发表于 2014-3-25 21:27
………………
Option Explicit
Sub 数据汇总() '要显示统计文件数
Dim Newapp As Excel.Application, iName$, wPath$, wName$
Dim wb As Workbook, Sht As Worksheet, iRng As Range, c As Range, n
Set iRng = Worksheets("汇总表").Range("C5,C6,C7,C8,E6,E20,E21,G5,G6,G7,G10,G14")
Application.ScreenUpdating = False
iRng.ClearContents
Set Newapp = CreateObject("Excel.Application")
With Newapp
.AutomationSecurity = msoAutomationSecurityForceDisable
.Visible = False
.DisplayAlerts = False
iName = ThisWorkbook.Name
wPath = ThisWorkbook.Path
wName = Dir(wPath & "\*.xls")
Do While wName <> "" And wName <> iName
n = n + 1
Set wb = .Workbooks.Open(wPath & "\" & wName, ReadOnly:=True)
With wb.wb.Sheets("报表3")
For Each c In iRng.Cells
c.Value = c.Value + .Range(c.Address)
Next
End With
wb.Close False
wName = Dir
Loop
.Quit
.DisplayAlerts = True
End With
Set Newapp = Nothing
Application.ScreenUpdating = True
MsgBox "数据汇总完成!" & "共汇总文件 " & n & " 个。", , "统计系统提示您" '一行显示
'MsgBox "数据汇总完成!" & vbCrLf & vbCrLf & "统计文件" & n & "个!"'二行显示
End Sub
我改成这样怎么不行呀,想在这个代码的基础上改,麻烦老师了!!!
|
|