Results 1 to 5 of 5

Thread: Macro to Delete Rows of Extraneous Data

  1. #1
    Junior Member
    Join Date
    Sep 2015
    Posts
    8
    Rep Power
    0

    Macro to Delete Rows of Extraneous Data

    I have a huge text file that I import on a monthly basis to Excel but need a macro that would delete rows except for those that has data between a cell that starts with "----" and ends with a "G/L Total:" in column A. Note that it's exactly 4 hyphens.

    Those two elements ("----" and "G/L Total:") are repeated at different rows in column A. Note that there are some blank cells in column A but not in between those two elements. If there are any blank cells in column A then the entire row should also be deleted.

    For example, there is extraneous rows of data from A1:A100 which includes blank rows, then A101 will start with "----" and have rows of data say until A120 where the last line will say "G/L Total:" Then in A121 there is extraneous data again until A180 then A181 will start with "----" and have rows of data say until A220, where the last line will say "G/L Total:" So the macro should delete the extraneous data (A1:A100 and A121:A180) including any rows where a cell in column A is empty and only display the data that is between "----" and "G/L Total:" (A101:A120 and A181:A220) for the entire spreadsheet.

    Thanks in advance.
    Last edited by showtyme; 09-10-2015 at 09:52 AM.

  2. #2
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    12
    I'd be more interested in seeing a part of the text file.

  3. #3
    Junior Member
    Join Date
    Sep 2015
    Posts
    8
    Rep Power
    0
    Quote Originally Posted by snb View Post
    I'd be more interested in seeing a part of the text file.
    It's pretty straight forward, was the example not clear?

  4. #4
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    659
    Rep Power
    13
    Quote Originally Posted by showtyme View Post
    It's pretty straight forward, was the example not clear?
    Should the rows with the four dashes and the "G/L Total" text in them be deleted or retained?

    Are there any formulas in Column A?

    Do you have any formulas on the worksheet anywhere?

  5. #5
    Junior Member
    Join Date
    Sep 2015
    Posts
    8
    Rep Power
    0
    Quote Originally Posted by Rick Rothstein View Post
    Should the rows with the four dashes and the "G/L Total" text in them be deleted or retained?

    Are there any formulas in Column A?

    Do you have any formulas on the worksheet anywhere?
    For now lets have the four dashes and "G/L Total" text be retained.
    No formulas in column A - I import the data from a text file to Excel then I have to reformat it by going through all those lines.
    No formulas are all values

    Also need to make sure rows are deleted if any cell in column A is empty.

    Thanks.

Similar Threads

  1. Replies: 3
    Last Post: 07-27-2014, 10:03 PM
  2. Replies: 8
    Last Post: 04-20-2014, 10:15 PM
  3. search for data and delete rows containing it
    By RickStewart in forum Excel Help
    Replies: 2
    Last Post: 02-24-2014, 09:12 PM
  4. Replies: 6
    Last Post: 08-14-2013, 04:25 PM
  5. Replies: 5
    Last Post: 07-11-2013, 07:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •