|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST()
Dim Items As FileDialogSelectedItems, strPath$, strName$
Dim strResult$(), ar, br, y&, x&, r&, j&, n As Byte
strPath = ThisWorkbook.Path & "\"
With Application.FileDialog(1)
With .Filters
.Clear
.Add "文本文件(txt)", "*.txt"
End With
.AllowMultiSelect = False
.InitialFileName = strPath
If .Show Then Set Items = .SelectedItems Else Exit Sub
End With
Application.ScreenUpdating = False
n = FreeFile
Open Items(1) For Input As #n
ar = Split(StrConv(InputB(LOF(n), #n), vbUnicode), vbCrLf)
Close #n
r = 0
ReDim strResult(1 To 10 ^ 4, 1 To 6)
For y = 0 To UBound(ar)
If InStr(ar(y), "网元 :") Then strName = Split(ar(y), "网元 :")(1)
If InStr(ar(y), "NULL ") Then
r = r + 1
strResult(r, 1) = strName
br = Split(ar(y))
n = 1
For j = 0 To UBound(br)
If Len(br(j)) Then
n = n + 1
strResult(r, n) = br(j)
End If
Next j
End If
Next y
[A1].CurrentRegion.Offset(1).Clear
With [A2].Resize(r, UBound(strResult, 2))
.Value = strResult
End With
Set Items = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
3
查看全部评分
-
|