Macro for Deleting Specific Rows?
On Aug 14, 9:06 pm, ryguy7272
wrote:
Sub delete_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
Try this:
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A").Value = "" Or Cells(RowNdx, "A").Value = "----------"
Or Cells(RowNdx, "A").Value = "total" Or Cells(RowNdx, "A").Value =
"subtotal" Then 'Change the "A" to another Column is needed
Rows(RowNdx).Delete
End If
Next RowNdx
End Sub
Regards,
Ryan---
--
RyGuy
"cardan" wrote:
Hello all,
I am seeking help regarding a new accounting system that imports info
into excel. When it imports, it leaves blank rows as well as rows
with "----------" in it. It also gives totals and subtotals under
certain categories.
I would like to delete the blank rows, delete the rows with the
"---------" as well as delete the rows that have the category totals.
Is there a macro out there where I could identify and delete rows with
these criteria? Any help would be greatly appreciated. Thank you for
your time in advance.- Hide quoted text -
- Show quoted text -
RyGuy, Thank you for the response. The Macro works, for the most
part, however there are some issues on my end. I realized that when I
import the numbers from the accounting program, "blank" cells are
actually not blank. Even though there are no number or anything in
them, Excel still picks up something in them. When I highlight the row
in question and hit delete, then run the macro, it will only then read
the rows as blank and delete them. I tried changing your formula from
"" to 0 but that also does not work.
Also the rows with "totals" in them that I need to get rid of contain
the word total with the heading name as well. ie Total Finance, Total
Design, etc... Is there a way I can get rid of a row in a column
contains the word "Total"?
Thank you for your help. I am very appreciative!
|