ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Filtered Rows - without deleting column headings (https://www.excelbanter.com/excel-programming/311603-delete-filtered-rows-without-deleting-column-headings.html)

DENISE

Delete Filtered Rows - without deleting column headings
 
I have the following code that filters the rows that I
want to delete, however it also deletes the column
headings. How do I change it to preserve the headings?
Thanks in advance for your help.

' Find the rows that do not have a D or a Z in column C
' and delete them. Cells with D are orders rows, cells
' with Z are Sales Doc rows.
Columns("C:C").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<Z*",
Operator:=xlAnd, _
Criteria2:="<D*"
Cells.SpecialCells(xlCellTypeVisible).EntireRow.De lete


Ron de Bruin

Delete Filtered Rows - without deleting column headings
 
Hi Denise

See how Tom use rng2 in this example to copy
http://www.contextures.com/xlautofilter03.html#Copy
You can adapt the code to delete

My new Addin can do this also
http://www.rondebruin.nl/easyfilter.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Denise" wrote in message ...
I have the following code that filters the rows that I
want to delete, however it also deletes the column
headings. How do I change it to preserve the headings?
Thanks in advance for your help.

' Find the rows that do not have a D or a Z in column C
' and delete them. Cells with D are orders rows, cells
' with Z are Sales Doc rows.
Columns("C:C").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<Z*",
Operator:=xlAnd, _
Criteria2:="<D*"
Cells.SpecialCells(xlCellTypeVisible).EntireRow.De lete





All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com