Results 1 to 4 of 4

Parse Text file

Threaded View

  1. #1
    Registered User
    Join Date
    06-23-2011
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    28

    Parse Text file

    I have coded this so far:

    Sub FileName()
    ' Open file and place content into worksheet.
    
        Dim dlgOpen As FileDialog
        Dim fields As String, FileName As String, target As String
        Dim fileHandle As Integer
        Dim i As Long, j As Long
    
    
        Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
        With dlgOpen
            'we want just the one file
            .AllowMultiSelect = False
            .Show
            For i = 1 To .SelectedItems.Count
                FileName = .SelectedItems(i)
            Next
        End With
        
        'get counter ready
        j = 0
        
        'prepare the file handle
        fileHandle = FreeFile()
    
        Open FileName For Input As fileHandle
        Do Until EOF(fileHandle)
            Line Input #fileHandle, fields
    
            Range("A1").Offset(j, 0).Value = fields
            j = j + 1
               
        Loop
    
        Close #1
    
    End Sub
    Once the file is inputted into the excel sheet it all goes into column A. I want to use vba to separate each column the end results should have column A and B filled. Attach is the file I used to open and wanting to parse.
    Attached Files Attached Files
    Last edited by noodle48; 07-22-2011 at 12:06 PM. Reason: Solved

Thread Information

Users Browsing this Thread

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

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