Holiday_Drew
New Member
- Joined
- Sep 14, 2017
- Messages
- 29
Hi Guys,
Hoping for your help I want to get specific information from .txt file I already get it and it worked but the problem it will only worked if on 1 txt file there is 1 needed information but when there are 3 information on 1 txt file I can't get all please see below the code that I use Sir Rick give it to me thanks to him.
Private Sub CommandButton1_Click()
Dim X As Long, B As Long, FileNum As Long
Dim TotalFile As String, Path As String, Filename As String
Dim Bytes As Variant, Percents() As String, Packets() As String, Txt() As String
Path = "C:\Users\CEN00028\Desktop\NEW IP TEL MONITORING Logs\VG Logs"
Filename = Dir$(Path & "*.log")
Do While Len(Filename)
FileNum = FreeFile
Open Path & Filename For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum , , TotalFile
Close #FileNum
Packets = Split(TotalFile, "CPU utilization", , vbTextCompare)
ReDim Percents(1 To UBound(Packets), 1 To 1)
B = 0
For X = 1 To UBound(Packets)
B = B + 1
Percents(B, 1) = Format(Val(Split(Packets(X), "five minutes:")(1)) / 100, "0%")
Next
With Cells(Rows.Count, "D").End(xlUp).Offset(1).Resize(B, 1)
.Value = Percents
.Value = .Value
End With
Filename = Dir$
Loop
End Sub
Thanks a lot! More Power to MREXCEL!
Hoping for your help I want to get specific information from .txt file I already get it and it worked but the problem it will only worked if on 1 txt file there is 1 needed information but when there are 3 information on 1 txt file I can't get all please see below the code that I use Sir Rick give it to me thanks to him.
Private Sub CommandButton1_Click()
Dim X As Long, B As Long, FileNum As Long
Dim TotalFile As String, Path As String, Filename As String
Dim Bytes As Variant, Percents() As String, Packets() As String, Txt() As String
Path = "C:\Users\CEN00028\Desktop\NEW IP TEL MONITORING Logs\VG Logs"
Filename = Dir$(Path & "*.log")
Do While Len(Filename)
FileNum = FreeFile
Open Path & Filename For Binary As #FileNum
TotalFile = Space(LOF(FileNum))
Get #FileNum , , TotalFile
Close #FileNum
Packets = Split(TotalFile, "CPU utilization", , vbTextCompare)
ReDim Percents(1 To UBound(Packets), 1 To 1)
B = 0
For X = 1 To UBound(Packets)
B = B + 1
Percents(B, 1) = Format(Val(Split(Packets(X), "five minutes:")(1)) / 100, "0%")
Next
With Cells(Rows.Count, "D").End(xlUp).Offset(1).Resize(B, 1)
.Value = Percents
.Value = .Value
End With
Filename = Dir$
Loop
End Sub
Thanks a lot! More Power to MREXCEL!