|
参与一下。。。
- Sub ykcbf() '//2024.7.22
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path & ""
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = p
- .Title = "请选择对应Excel文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Excel文件", "*.xls*"
- If .Show Then f = .SelectedItems(1) Else Exit Sub
- End With
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("汇总")
- r = .Cells(Rows.Count, 2).End(3).Row
- arr = .[a1].Resize(r, 10)
- End With
- wb.Close 0
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- For i = 4 To UBound(arr)
- If arr(i, 2) <> Empty Then
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- With sh
- .UsedRange.Offset(4).ClearContents
- .[a5].Resize(m, UBound(arr, 2)) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|