|
Option Explicit
Sub TEST()
Dim ar$(), i&, n&, strTxt$, strPath$, strFileName$
strPath = ThisWorkbook.Path & "\"
strFileName = strPath & "\客户信息.txt"
If strFileName = "" Then Exit Sub
Application.ScreenUpdating = False
Cells.Clear
strTxt = ReadFromTextFile(strFileName)
ar = Split(strTxt, vbLf)
For i = 0 To UBound(ar)
If Left(ar(i), 2) = "北京" Then
n = n + 1
Cells(n, 1).Value = ar(i)
End If
Next i
Application.ScreenUpdating = True
Beep
End Sub
Function ReadFromTextFile$(ByVal strFullName$, _
Optional ByVal strCharSet$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Type = 2
.Mode = 3
.Charset = strCharSet
.Open
.LoadFromFile strFullName
ReadFromTextFile = .ReadText
.Close
End With
End Function
|
评分
-
1
查看全部评分
-
|