%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Sub process() Dim FileName As Variant Dim str Dim m, posA, posB As Integer Dim A, B, C As String
FileName = Application.GetOpenFilename(FileFilter:="文本文档(*.txt),*.TXT") Open FileName For Input As #1 Worksheets("sheet1").Cells.NumberFormatLocal = "@"
m = 2 If FileName = "" Then Exit Sub End If
A = Worksheets("sheet1").Cells(1, 1) B = Worksheets("sheet1").Cells(1, 2) C = Worksheets("sheet1").Cells(1, 3) Worksheets("sheet1").Range("a2:IV65535").ClearContents
Do While Not EOF(1) Line Input #1, str
posA = InStr(str, A) posB = InStr(str, B) If posA <> 0 And posB <> 0 Then Worksheets("sheet1").Cells(m, 1) = Mid(str, posA + Len(A), posB - posA - Len(A)) & C End If