+ Reply to Thread
Results 1 to 4 of 4

Open Text file

  1. #1
    Registered User
    Join Date
    08-26-2010
    Location
    Poplar Bluff MO
    MS-Off Ver
    Excel 2016
    Posts
    98

    Open Text file

    I need a macro that will prompt the user to open a .txt file and bring into excel and separate columns based on fixed width like below.

    12, 51, 60, 63, 68, 75, 79, 83, 90, 93, 97, 104, 107, 111, 118, 121, 125.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Open Text file

    But that's not a fixed width. But delimited by comma.

    I.E. 12, has different width than 121,

    Can't you just use native text import wizard?

    0.JPG
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    08-26-2010
    Location
    Poplar Bluff MO
    MS-Off Ver
    Excel 2016
    Posts
    98

    Re: Open Text file

    I could but the person using this file is very excel naïve. I thought I could add this to the macro I already have her using. She doesn't think she can handle opening a text file and then splitting the columns into the right fields.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Open Text file

    VBA is more prone to error than import wizard. As you need to code to handle errors etc.

    If you must, I'd start off by recording the steps you take to import the file using text wizard (using macro recorder). That will give you the code base to customize.
    It will be easier for you to maintain than custom codes, I'd imagine.
    Ex:
    Please Login or Register  to view this content.
    Now you just have to customize it to suite your need.


    If you are interested in importing text file through methods other than native Excel tool, google "freefile() and import text file", you will find plenty of example on it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Open text file in sheet 2, from file dialog box
    By chrisjd2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2016, 11:16 AM
  2. Replies: 0
    Last Post: 02-09-2016, 06:14 PM
  3. Open an excell file or text file or pdf from anywhere in the system
    By catchnanan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2013, 04:13 PM
  4. looping, Open text file, copy text, close text file
    By jwilds1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2009, 05:12 PM
  5. Replies: 0
    Last Post: 06-25-2007, 11:56 AM
  6. [SOLVED] Open CSV file, format data and write output to a text file.
    By BristolBloos in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 11:05 AM
  7. [SOLVED] How do I import text file, analyze data, export results, open next file
    By Geoffro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2005, 04:06 PM

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