PDA

View Full Version : Macro to Delete Rows of Extraneous Data



showtyme
09-10-2015, 09:36 AM
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.

snb
09-10-2015, 11:26 AM
I'd be more interested in seeing a part of the text file.

showtyme
09-10-2015, 06:25 PM
I'd be more interested in seeing a part of the text file.

It's pretty straight forward, was the example not clear?

Rick Rothstein
09-10-2015, 11:27 PM
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?

showtyme
09-11-2015, 12:28 AM
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.