+ Reply to Thread
Results 1 to 3 of 3

Importing fixed width .txt files

  1. #1
    Registered User
    Join Date
    09-08-2014
    Location
    -
    MS-Off Ver
    -
    Posts
    68

    Importing fixed width .txt files

    Greetings,
    In my userform, the user has to specify the location of three files.
    I want each of these files, in turn, to be copied to a location on my workbook (So, destination = Worksheets("SLRisk Data").Range("A1") ).
    It will then run some code to copy relevant sections to another worksheet (that bit is fine).
    Afterwards, I want it to delete the data it just copied on to the SLRisk Data worksheet, and do it for the next file (so it'll do this three times).


    Anyhow, I've looked online and I can't get any of the 'import fixed with' things working. It'll import the table but the format goes completely skewed to the point of uselessness.

    I tried recording a macro to import the data - now, this kind of works. The issue is that I want the macro to use my TextBox1.Value as the data for the filepath, but it only accepts a string - it won't allow variables defined as strings or, well, anything deviating from "C:\Users\Folder\Folder\Folder\File.txt"

    Here's the code which recording a macro gets me:

    Please Login or Register  to view this content.
    So, obviously, I want to change the bold bit - this is where I'm struggling. Any suggestions?
    Thanks.

    EDIT: Just as an example, I tried doing the following:

    Please Login or Register  to view this content.
    It didn't work - I tried removing quotation marks and whatnot... I even tried making the filname string include everything between .Add( and the last brackeft before .Name and couldn't get it working. *cry*
    Last edited by MarmaladeLover; 09-12-2014 at 05:49 AM.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Importing fixed width .txt files

    Please Login or Register  to view this content.
    where filename is variable holding the file name and path
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Registered User
    Join Date
    09-08-2014
    Location
    -
    MS-Off Ver
    -
    Posts
    68

    Re: Importing fixed width .txt files

    I refreshed this several many times over today and it told me nobody had posted, but you solved my problem ages ago >.< Thanks! Working fabulously now.

+ 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. Importing Fixed Width Text Data Into Excel
    By jgsuf in forum Excel General
    Replies: 3
    Last Post: 08-21-2014, 01:48 PM
  2. Problem with importing multiple data files with fixed width format
    By sport_logo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-21-2010, 07:34 AM
  3. Importing file with fixed width, multi-line records
    By danmcgov in forum Excel General
    Replies: 7
    Last Post: 03-20-2006, 04:10 PM
  4. [SOLVED] Importing Fixed Width File Macro
    By Himansu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2005, 01:05 PM
  5. Basic Q: Field/Array info when importing fixed-width text files
    By KR in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2005, 05: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