Closed Thread
Results 1 to 3 of 3

Need Code Modification for Text file to Excel File

  1. #1
    Forum Contributor
    Join Date
    12-16-2013
    Location
    World
    MS-Off Ver
    Excel 2007
    Posts
    215

    Question Need Code Modification for Text file to Excel File

    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.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by pvsvprasad; 08-17-2016 at 07:19 AM.

  2. #2
    Forum Contributor
    Join Date
    12-16-2013
    Location
    World
    MS-Off Ver
    Excel 2007
    Posts
    215

    Re: Need Code Modification for Text file to Excel File

    Kindly suggest above mentioned code with minor modification for adding 2 more columns only. and prepare updated code.

    Thanking you all,
    Best regards.
    Last edited by pvsvprasad; 08-17-2016 at 12:48 PM.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2407
    Posts
    25,860

    Re: Need Code Modification for Text file to Excel File

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VB Code to get the Modification date of excel file
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-11-2016, 10:43 AM
  2. Loop through Code that copies the content of a text file to another text file
    By michiel soede in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2013, 01:34 PM
  3. VBA code for aligning excel file converted from text file.
    By anbub1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2013, 12:44 PM
  4. [SOLVED] Slight Modification Request VBA Code - Text File to Excel
    By spiwere in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 03-22-2013, 04:39 AM
  5. Macro to check for file modification and display a pop-up or reload the client file.
    By Askander in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-02-2011, 09:26 AM
  6. VBA code to import text file to the fixed excel file
    By wangdian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-30-2010, 10:13 AM
  7. Excel file modification date
    By GROSNER in forum Excel General
    Replies: 5
    Last Post: 03-03-2005, 10:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1