|
具体的封装代码
Sub dt()
Dim lngCount As Long
Dim s(100)
Dim NUM As Integer
book_name = ActiveWorkbook.Name
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show
For lngCount = 1 To .SelectedItems.Count
NUM = lngCount
s(NUM) = .SelectedItems(lngCount)
Next lngCount
End With
Application.DisplayAlerts = False
For kk = 1 To 10
On Error Resume Next
Sheets("xl" & kk).Select
If Err.Number <> 0 Then
Err.Clear
GoTo a0
End If
ActiveWindow.SelectedSheets.Delete
a0: Next kk
On Error GoTo 0
m = 1
h = 65535
aa = 0
JJ = 0
a0 = 0
a1 = 0
A2 = 0
A3 = 0
A4 = 0
A5 = 0
A6 = 0
A7 = 0
B0 = 0
B1 = 0
B2 = 0
For NUM = 1 To Application.FileDialog(msoFileDialogOpen).SelectedItems.Count
Set fso = New FileSystemObject
Set xText = fso.OpenTextFile(s(NUM))
Do While Not xText.AtEndOfStream
strLine = xText.ReadLine
j = Trim(strLine)
'MsgBox j
'If InStr(1, j, "Measurement Result", 1) > 0 And InStr(1, j, "MSISDN: 13226444742;", 1) > 0 Then
If InStr(1, j, "Measurement Result", 1) > 0 Then
hh = hh + 1
k1 = Right(j, 47)
k2 = Mid(k1, 1, 2)
k3 = Right(j, 50)
k4 = Mid(k3, 1, 2)
k5 = Right(j, Len(j) - InStr(1, j, "7F F0", 1) + 1)
k6 = Mid(k5, 124, 2)
k7 = Mid(k5, 127, 2)
k8 = Mid(k5, 91, 2) 'Handover Triggered Indication(HoCause)
JJ = JJ + 1
If h > 65534 Then
Sheets.Add.Name = "XL" & m
m = m + 1
h = 2
Sheets("XL" & m - 1).Cells(1, 5) = "ÏÂÐеçƽ"
Sheets("XL" & m - 1).Cells(1, 6) = "ÏÂÐÐÖÊÁ¿"
Sheets("XL" & m - 1).Cells(1, 7) = "ÉÏÐеçƽ"
Sheets("XL" & m - 1).Cells(1, 8) = "ÉÏÐÐÖÊÁ¿"
Sheets("XL" & m - 1).Cells(h, 5) = "ÏÂÐеçƽ"
Sheets("XL" & m - 1).Cells(h, 6) = "ÏÂÐÐÖÊÁ¿"
Sheets("XL" & m - 1).Cells(h, 7) = "ÉÏÐеçƽ"
Sheets("XL" & m - 1).Cells(h, 8) = "ÉÏÐÐÖÊÁ¿"
End If
Sheets("XL" & m - 1).Cells(h, 1) = k4
Range("e" & h).Select
ActiveCell.FormulaR1C1 = "=bIN2DEC(Mid(HEX2BIN(RC[-4], 8),3, 6)) - 110"
Sheets("XL" & m - 1).Cells(h, 2) = k2
Range("f" & h).Select
ActiveCell.FormulaR1C1 = "=BIN2OCt(Mid(HEX2BIN(RC[-4], 8), 5,3))"
Sheets("XL" & m - 1).Cells(h, 3) = k6
Range("g" & h).Select
ActiveCell.FormulaR1C1 = "=BIN2DEC(right(HEX2BIN(RC[-4], 8), 6)) - 110"
Sheets("XL" & m - 1).Cells(h, 4) = k7
Range("h" & h).Select
ActiveCell.FormulaR1C1 = "=BIN2OCt(right(HEX2BIN(RC[-4], 8), 3))"
h = h + 1
End If
Loop
xText.Close
Next NUM
' Workbooks.Open Filename:=s(NUM)
'book_name1 = ActiveWorkbook.Name
End Sub |
|