|
Option Explicit
Sub test()
Dim ar, br, i&, n&, strFileName$, strPath$
strPath = ThisWorkbook.Path & "\"
strFileName = strPath & "原始数据.xlsm"
If Dir(strFileName) = "" Then MsgBox "指定的文件不存在,请检查!", vbExclamation: Exit Sub
Application.ScreenUpdating = False
ReDim ar(1 To 24)
With GetObject(strFileName)
br = .Worksheets(1).[A2].CurrentRegion.Value
For i = 1 To 10
If i > UBound(br) Then Exit For
ar(i) = br(i, 1)
Next i
n = UBound(br) + 1
For i = 15 To 24
n = n - 1
If n = 0 Then Exit For
ar(i) = br(n, 1)
Next i
.Close False
End With
[B5].Resize(, UBound(ar)) = ar
Application.ScreenUpdating = True
Beep
End Sub
|
|