|
liurongyue 发表于 2014-11-22 13:55
需要复制每个表的E列和J列并汇总
Sub zz()
Dim f$, p$, wb As Workbook, a(1 To 36, 1 To 1), b(1 To 36, 1 To 1), a1, b1, c
Application.ScreenUpdating = False
Set wb = ThisWorkbook
wb.Sheets("sheet1").[a2].Resize(100, 100).ClearContents
wb.Sheets("汇总表").Range("b:b,d:d").ClearContents
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls")
Do While Len(f)
If f <> ThisWorkbook.Name Then
With GetObject(p & f)
a1 = .Sheets(1).Range("e3:e38")
b1 = .Sheets(1).Range("j3:j38")
c = Split(f, ".")(0)
.Close False
End With
With wb.Sheets("Sheet1")
.Cells(3, 1 + n).Resize(UBound(a1), 1) = a1
.Cells(3, 2 + n).Resize(UBound(b1), 1) = b1
.Cells(2, 1 + n) = c
n = n + 3
End With
For i = 2 To UBound(a)
a(i, 1) = a(i, 1) + a1(i, 1)
b(i, 1) = b(i, 1) + b1(i, 1)
Next
End If
f = Dir
Loop
Sheet1.[b3].Resize(UBound(a)) = a
Sheet1.[d3].Resize(UBound(b)) = b
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|