+ Reply to Thread
Results 1 to 5 of 5

VBA to read in tab delimited text file

  1. #1
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Cool VBA to read in tab delimited text file

    Hi, I have the below code which reads in a tab delimited file however how do I tweak this so it only brings back data that I want.
    For example, if I want to see only those entries where the first field is 123 how do I go about doing that? At the moment this code will read in all entries from within the tab delimited file.

    Many thanks

    Please Login or Register  to view this content.

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

    Re: VBA to read in tab delimited text file

    Try this. It uses the Split function to divide the delimited data of a given line.
    The If-End If code block is the filter where the zero is the field number (1st column = 0, 2nd column = 1...)

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: VBA to read in tab delimited text file

    Thanks Alpha Frog that works exactly as I wanted it to.
    If I wanted to only bring back this but within a certain date range e.g. reference 123 only where column 3 is greater than or equal to 01/01/16 and column 4 being less than or equal to 01/04/16- could this be added to the below extract you did above?

    I guess column 3 would be varTemp(2) and 4 varTemp(4)?

    Please Login or Register  to view this content.

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

    Re: VBA to read in tab delimited text file

    Quote Originally Posted by DaveNUFC View Post
    Thanks Alpha Frog that works exactly as I wanted it to.
    If I wanted to only bring back this but within a certain date range e.g. reference 123 only where column 3 is greater than or equal to 01/01/16 and column 4 being less than or equal to 01/04/16- could this be added to the below extract you did above?

    I guess column 3 would be varTemp(2) and 4 varTemp(4)?
    I didn't test this...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: VBA to read in tab delimited text file

    Thanks Alpha, works great ;-)

+ 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. Script/macro to save a copy as tab delimited text file and then close original file
    By Merlin803 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2015, 01:34 PM
  2. conversion of text file(delimited) into Excel file using macro
    By thara.p24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2014, 08:35 AM
  3. Read Tab delimited file breaks at commas
    By patrikquick in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2011, 07:05 AM
  4. Saving multi-tab excel file created from comma delimited text file
    By Marcus Aurelius in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2005, 01:20 PM
  5. Replies: 1
    Last Post: 05-03-2005, 06:06 PM
  6. [SOLVED] Export excel file to semicolon delimited text file
    By capitan in forum Excel General
    Replies: 5
    Last Post: 04-06-2005, 11:07 PM
  7. Export excel file to semicolon delimited text file
    By capitan in forum Excel General
    Replies: 5
    Last Post: 04-06-2005, 11:07 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