+ Reply to Thread
Results 1 to 2 of 2

Skipping rows while importing a text file if a field contains 0

  1. #1
    Registered User
    Join Date
    02-21-2011
    Location
    Sliema, Malta
    MS-Off Ver
    Excel 2003
    Posts
    1

    Skipping rows while importing a text file if a field contains 0

    I am importing a tab delimited text file and need to skip rows, that is not to import row, whose 4th field (column) is equal to zero. My current code is:
    Please Login or Register  to view this content.

    The following is a sample of the imported text, but I do not want to import the 3rd and 6th rows as their value is 0.00
    34000001 INV 28-Dec-06 796.3
    34000002 INV 24-Jan-07 23.29
    34000002 INV 29-Jan-07 0.00
    34000005 INV 31-Jan-07 139.76
    34000005 PAY 31-Jan-07 796.3
    34000005 INV 15-Mar-07 0.00
    34000007 PAY 24-Mar-07 186.35
    34000007 PAY 25-Apr-07 273.7

    Would appreciate a solution. Thank you in anticipation.
    34000008 INV 22-Jun-07 19.8
    Last edited by Leith Ross; 02-21-2011 at 03:39 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Skipping rows while importing a text file if a field contains 0

    Hello fgingell,

    Welcome tot he Forum!

    You can actually skip lines in a text file using the text import method. Rather, you have to check the data once it has been transferred onto the worksheet and delete rows accordingly. based on you r example, the macro assumes the sample shown to be in columns "A" through "D". A second macro will examine each cell in column "D" and delete the row if it has a zero value. A call is made from the first macro to second, after the data has been imported.

    Amended First Macro
    Please Login or Register  to view this content.

    Second Macro to Delete Rows
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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