Dear All Practicing Programmers and Senior Programmers,
i have a code from one of the well wisher from this site.
i need small modification in existing code, please modify for extra column.
Please find attachments of Text file, sample excel output file.
My Existing code as below:
Sub test()
Dim fn As String, txt As String, n As Long, m As Object, mtch As Object, sm As Object, a()
fn = Application.GetOpenFilename("TextFiles,*.anl")
If fn = "False" Then Exit Sub
txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
With CreateObject("VBScript.RegExp")
.Global = True: .MultiLine = True
.Pattern = "^ *=+(\r\n)([^=]+\r\n)+"
Set mtch = .Execute(txt)
ReDim a(1 To mtch.Count)
.Pattern = "^ +(.*?) +N O\. +(\d+)(.*\r\n){4}.*?: +(\d+\.\d+).*?: +(\d+\.\d+).*?X +(\d+\.\d+).*"
For Each m In mtch
If .test(m) Then
n = n + 1: Set sm = .Execute(m)(0).submatches
a(n) = Array(n, sm(0), sm(1), sm(3), sm(4), sm(4))
End If
Next
End With
If n > 0 Then
ReDim Preserve a(1 To n)
[a2].Resize(n, 6).Value = Application.Index(a, 0, 0)
End If
Range("B2:F14").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlNo
Columns(1).ClearContents
End Sub
Thanking you sir,
Best regards.
Bookmarks