|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test()
Dim strFileName$, strPath$, strResult$(), ar, br, i&, j&, r&, n As Byte, strName$
DoApp False
ReDim strResult(1 To 10 ^ 4, 1 To 3)
r = r + 1
br = Split("编号 设备特征码 文件号")
For j = 0 To UBound(br)
strResult(r, j + 1) = br(j)
Next j
strPath = ThisWorkbook.Path & "\"
strFileName = Dir(strPath & "*.csv")
Do Until strFileName = ""
n = FreeFile
Open strPath & strFileName For Input As #n
ar = Split(StrConv(InputB(LOF(n), #n), vbUnicode), vbLf)
Close #n
strName = Left(strFileName, InStrRev(strFileName, ".") - 1)
For i = 0 To UBound(ar)
br = Split(ar(i), ";")
If br(0) = "A" Then
r = r + 1
strResult(r, 1) = Split(br(2), "|")(0)
strResult(r, 2) = Split(br(2), "|")(1)
strResult(r, 3) = strName
End If
Next i
strFileName = Dir
Loop
[A1].CurrentRegion.Clear
[A1].Resize(r, 3) = strResult
DoApp
Beep
End Sub
Function DoApp(Optional b As Boolean = True)
With Application
.ScreenUpdating = b
.DisplayAlerts = b
.Calculation = -b * 30 - 4135
End With
End Function
|
评分
-
2
查看全部评分
-
|