|
- Sub 导入文件()
- Application.ScreenUpdating = False
- Dim Filename, wb As Workbook, Sht As Worksheet
- Filename = Dir(ThisWorkbook.Path & "\*.xls")
- Dim brr(1 To 1000, 1 To 15)
- Set d = CreateObject("scripting.dictionary")
- Do While Filename <> ""
- If Filename <> ThisWorkbook.Name Then
- fn = ThisWorkbook.Path & "" & Filename
- Set wb = Workbooks.Open(fn)
- wb.Worksheets(1).Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
- With ActiveSheet
- .Name = Split(wb.Name, ".")(0)
- r = .[a65536].End(3).Row
- If r >= 4 Then
- arr = .Range("a4:o" & .[a65536].End(3).Row)
- For i = 1 To UBound(arr)
- x = arr(i, 1)
- If Len(x) > 0 Then
- If Not d.exists(x) Then
- n = n + 1
- d(x) = n
- brr(n, 1) = x
- End If
- p = d(x)
- For j = 2 To UBound(arr, 2)
- If arr(i, j) <> 0 Then brr(p, j) = brr(p, j) + arr(i, j)
- Next
- End If
- Next
- End If
- End With
- wb.Close False
- End If
- Filename = Dir
- Loop
- Set Sht = Nothing
- With Sheet1
- .[a4:o1000].ClearContents
- .[a4].Resize(n, 15) = brr
- .Activate
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|