|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub test()
Dim Wk As Workbook, Sht1 As Worksheet
Dim My1$, My2$, My3$, My4$, My5$
Dim arr, brr, str$
Dim Myr%
Dim i%, j&, m%, n%
Dim crr(), drr
Application.ScreenUpdating = False
My1 = ThisWorkbook.Path & "\"
My2 = "abc.txt"
My3 = Dir(My1 & My2)
My4 = My1 & "\" & My3
Set Sht1 = Sheet1
r = 0
While My3 <> ""
Open My4 For Input As #1
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbLf)
Close #1
j = 0
ReDim crr(1 To UBound(arr) + 1, 1 To 6)
For j = 0 To UBound(arr)
If InStr(arr(j), "|") > 0 Then
drr = Split(arr(j), "|")
If InStr("2,5", drr(2)) > 0 Then
k = k + 1
For i = 0 To UBound(drr)
crr(k, i + 1) = drr(i)
Next i
End If
End If
Next j
j = j + 1
With Sht1
.Cells(2, 1).Resize(UBound(crr), 6) = crr
End With
My3 = Dir
Wend
Application.ScreenUpdating = True
End Sub |
评分
-
1
查看全部评分
-
|