|
Sub 数据汇总()
Application.ScreenUpdating = False
Dim ww As Workbook, wb As Workbook
Dim d As Object
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
sh.[a1].CurrentRegion.Offset.Borders.LineStyle = 0
sh.[a1].CurrentRegion.Offset(2).UnMerge
sh.[a1].CurrentRegion.Offset(2).ClearContents
d(sh.Name) = ""
Next sh
Set ww = ThisWorkbook
lj = ww.Path & "\"
f = Dir(lj & "*.xls*")
Do While f <> ""
If f <> ww.Name Then
Set wb = Workbooks.Open(lj & f, 0)
For Each sh In wb.Worksheets
mc = sh.Name
If d.exists(sh.Name) Then
x = sh.Cells.Find("*", searchdirection:=xlPrevious).Row
y = sh.Cells.Find("*", searchdirection:=xlPrevious).Column
sh.Range(sh.Cells(3, 1), sh.Cells(x, y)).Copy
With ww.Worksheets(sh.Name)
yy = .Cells(2, Columns.Count).End(xlToLeft).Column
lh = Replace(Cells(1, yy).Address(0, 0), 1, "")
ws = .Columns("a:" & lh).Find("*", searchdirection:=xlPrevious).Row + 1
.Cells(ws, 1).Resize(x - 2, y).PasteSpecial Paste:=xlPasteValues
.Cells(ws, 1).PasteSpecial Paste:=xlPasteFormats
End With
End If
Next sh
wb.Close False
End If
f = Dir
Loop
Application.ScreenUpdating = True
MsgBox "汇总完毕!", 64, "提醒"
End Sub
|
|