|
Option Explicit
Sub test()
Dim strFileName$, strPath$, strResult$(), ar, br, y&, x&, r&, n As Byte
DoApp False
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), "就职")
Close #n
For y = 0 To UBound(ar)
If Len(ar(y)) Then
br = Split(ar(y), vbCrLf)
r = r + 1
ReDim Preserve strResult(1 To 3, 1 To r)
For x = 1 To 3
If x > 1 Then n = x + 1 Else n = 1
strResult(x, r) = br(n)
Next x
End If
Next y
strFileName = Dir
Loop
With [A1].CurrentRegion
ar = .Value
For x = 3 To UBound(ar)
For y = 4 To 5: ar(x, y) = Empty: Next
For y = 1 To UBound(strResult, 2)
If strResult(1, y) = ar(x, 2) Then
ar(x, 4) = strResult(2, y)
ar(x, 5) = strResult(3, y)
Exit For
End If
Next y
Next x
.Value = ar
End With
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
|
评分
-
3
查看全部评分
-
|