|
仅供参考,Excel可用,WPS没有试过
- Sub test()
- Application.ScreenUpdating = False
- Sheets("SHEET2").Range("A1").CurrentRegion.ClearContents
- Dim ARR, BRR
- ReDim BRR(1 To 1048576, 1 To 4)
- J = 1
- BRR(1, 1) = "序号"
- BRR(1, 2) = "项目"
- BRR(1, 3) = "时间"
- BRR(1, 4) = "累计量"
- ChDir ThisWorkbook.Path
- A = Application.GetOpenFilename("Excel文件,*.xls*", MultiSelect:=True)
- COST = Timer
- If IsArray(A) Then
- For I = LBound(A) To UBound(A)
- If A(I) <> ThisWorkbook.FullName Then
- Application.Workbooks.Open (A(I))
- ARR = ActiveWorkbook.Sheets(1).Range("A1").CurrentRegion
- ActiveWorkbook.Close False
- For II = LBound(ARR) + 1 To UBound(ARR)
- J = J + 1
- BRR(J, 1) = ARR(II, 1)
- BRR(J, 2) = ARR(II, 2)
- BRR(J, 3) = ARR(II, 3)
- BRR(J, 4) = ARR(II, 4)
- Next
- End If
- Next
- Sheets("SHEET2").Range("A1").Resize(J, 4) = BRR
- Sheets("SHEET2").Range("C:C").NumberFormat = "YYYY-MM-DD"
- MsgBox "完成,耗时:" & Format(Timer - COST, "0.00秒")
- Else
- MsgBox "NO SELECT"
- End If
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|