Extractacting needed information from .txt file to excel using VBA

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!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top