|
试试这个,看看是不是你想要的,文件放在同一目录下
- Sub t()
- Dim fs, f, pa, m%, arr, brr, i%, j%, r%, c%, wy, r_1%, r_end%, t
- pa = ThisWorkbook.Path & "/系统查询结果.txt"
- Set fs = Workbooks.Open(pa)
- m = [a1048576].End(xlUp).Row
- For i = m To 1 Step -1
- If VarType(Range("a" & i)) = 10 Then
- Rows(i).Delete shift:=xlUp
- ElseIf Range("a" & i) = "" Then
- Rows(i).Delete shift:=xlUp
- End If
- Next i
- Application.DisplayAlerts = False
- arr = ActiveSheet.Range("a1:a" & m)
- ReDim brr(1 To 10000, 1 To 6)
- fs.Save
- fs.Close
- Set fs = Nothing
- r = 1
- For i = 1 To UBound(arr)
- If arr(i, 1) <> "" Then
- k = arr(i, 1)
- If InStr(k, "网元") Then
- wy = Split(k, " : ")(1)
- ElseIf InStr(k, "柜号") Then
- r_1 = i + 1
- ElseIf InStr(k, "结果个数") Then
- r_end = i - 1
- For j = r_1 To r_end
- brr(r, 1) = wy
- t = Split(arr(j, 1), " ")
- c = 2
- For n = 0 To UBound(t)
- If t(n) <> "" Then
- brr(r, c) = t(n): c = c + 1
- End If
- Next n
- r = r + 1
- Next j
- End If
-
- End If
- Next i
- [a2].Resize(UBound(brr), 6) = brr
- Application.DisplayAlerts = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|