|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub test()
Dim strFileName$, strPath$, n As Byte
Dim vResult$(), ar, br, y&, x&, j&, r&
Application.ScreenUpdating = False
ReDim vResult(1 To 10 ^ 3, 8)
strPath = ThisWorkbook.Path & "\"
strFileName = Dir(strPath & "*.txt")
Do Until strFileName = ""
n = FreeFile
Open strPath & strFileName For Input As #n
ar = Split(StrConv(InputB(LOF(n), #n), vbUnicode), vbLf)
Close #n
r = r + 1
vResult(r, UBound(vResult, 2)) = Mid(strFileName, 4, 6)
For y = 2 To UBound(ar) - 2
br = Split(ar(y), vbTab)
If br(0) > vResult(r, 0) Then
For j = 0 To UBound(br)
vResult(r, j) = br(j)
Next j
End If
Next y
strFileName = Dir
Loop
Columns("A:I").Clear
[A1].Resize(r, UBound(vResult, 2) + 1) = vResult
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
4
查看全部评分
-
|