Results 1 to 4 of 4

Thread: [RESOLVED] Import txt file in excel

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    57

    Resolved [RESOLVED] Import txt file in excel

    Hello, I am trying to import a txt file into excel 2003.
    My problem is that i can't figure out how to make excel understand that the txt file is column based.
    I want to import the data exactly as i see them in txt, as a table.

    Code:
    Sub OpenFile()
    Dim A As Long, B As String, C As Variant, D As Variant, E As Variant
    Dim iRow    As Long
    Dim i As Long
    Dim Fname   As Variant
    Fname = Application.GetOpenFilename("Text Files (*.txt),*.txt", , _
             "Select Text Data File")
    If Fname = False Then Exit Sub
    Open Fname For Input As #1
    iRow = 1
    i = 1
    Do While Not EOF(1)
        Input #1, A
        Cells(1, i) = A
        'iRow = iRow + 1
        i = i + 1
    Loop
    Close 1
    End Sub
    I searched in here, but the other posts did not help me
    Attached Files Attached Files
    Last edited by manin; Oct 6th, 2009 at 07:06 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width