|
改好了。。。
- Sub ykcbf() '//2024.8.25
- Application.ScreenUpdating = False
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = ThisWorkbook.Path & ""
- .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(1)
- r = .Cells(Rows.Count, 2).End(3).Row
- ReDim arr(1 To r, 1 To 2)
- ReDim brr(1 To r, 1 To 2)
- For i = 2 To r
- If .Cells(i, 4) <> Empty Then
- m = m + 1
- arr(m, 1) = .Cells(i, 4)
- arr(m, 2) = .Cells(i, 5)
- brr(m, 1) = .Cells(i, 8)
- brr(m, 2) = .Cells(i, 9)
- End If
- Next
- End With
- wb.Close 0
- With Sheets("Sheet1")
- .[b2].Resize(m, 2) = arr
- .[f2].Resize(m, 2) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|