+ Reply to Thread
Results 1 to 5 of 5

Single Column Txt file

  1. #1
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Single Column Txt file

    For some reason, this macro can't import a single column text file. Can someone help me out with this?

    Please Login or Register  to view this content.
    Last edited by Bob1980; 12-21-2012 at 04:14 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Single Column Txt file

    The syntax looks correct. What exactly happens?

    You can step through each line of code (F8) in the VBA editor.

    Does it error? If yes, what's the error?
    Does the text file open?
    Does it import anything?
    What is the text in the text file

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Single Column Txt file

    this code works, check the sheet name on this line
    Set wsData = ActiveWorkbook.Sheets("AASTD Inj 1")
    If solved remember to mark Thread as solved

  4. #4
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Re: Single Column Txt file

    Yeah, it's funny cause it works on all of my other txt data.

    I get a Run-time error '9', Subscript out of range; on this line:

    Please Login or Register  to view this content.
    And then the macro creates a new spreadsheet book with the name of the txt file.Here's a sample of the data.
    Attached Files Attached Files
    Last edited by Bob1980; 12-21-2012 at 04:36 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Single Column Txt file

    The equal sign characters ("============") used as a section line separator within the text file is causing the error when you transfer the values to the sheet. Excel interprets a line that begins with an equal sign as a formula.

    This will import the text directly to the sheet without having to transfer the values.

    Please Login or Register  to view this content.

+ Reply to Thread

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