+ Reply to Thread
Results 1 to 5 of 5

Macro to Selectively Import Fixed Length Data into Excel

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Macro to Selectively Import Fixed Length Data into Excel

    I am attempting to modify VBA code from the following URL:

    http://www.cpearson.com/excel/ImportingFixedWidth.aspx

    The section of the code I want to modify is below dealing with importing selective text. The original function returned a "False" if the line contained a keyword specified in the Array function. I have reworked it so that it shows a "True" if the line contains a keyword specified in the Array function.

    My only problem is that it only does it when the keyword appears in the beginning of the line, as it uses the "Left" operator in looking at line. How do I configure the function so that it returns a "True" if the keywords appears anywhere in the line? 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: Macro to Selectively Import Fixed Length Data into Excel

    Please Login or Register  to view this content.
    Notes:
    This is case sensitive. (That could be easily changed).
    Partial word matches will yield a False e.g. CA will not match CAT.
    Last edited by AlphaFrog; 02-23-2014 at 10:38 PM.
    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
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Re: Macro to Selectively Import Fixed Length Data into Excel

    The problem I am have with this macro deals with your last statement "Partial word matches will yield a False e.g. CA will not match CAT."

    Because the keyword is part of a larger string (line) with no spaces, it is not returning a "True" value. Can your macro be modified to give a "True" for partial results?

  4. #4
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Re: Macro to Selectively Import Fixed Length Data into Excel

    Actually, was able to figure it out using the code below:

    Please Login or Register  to view this content.
    Thanks for help..

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

    Re: Macro to Selectively Import Fixed Length Data into Excel

    I thought you were trying to find two letter state codes.

    You could use this syntax as well...
    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)

Similar Threads

  1. Setting up for fixed length field import
    By chedderslam in forum Excel General
    Replies: 2
    Last Post: 08-19-2009, 04:03 PM
  2. Import Fixed Length File
    By tandrews in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-07-2007, 12:19 PM
  3. import fixed-length text file into excel
    By GottaRun in forum Excel General
    Replies: 4
    Last Post: 02-19-2006, 09:16 PM
  4. Fixed length file import??
    By Trey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2006, 04:50 PM
  5. Replies: 1
    Last Post: 05-09-2005, 02: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