ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if filtered cells contain data to delete (https://www.excelbanter.com/excel-programming/374216-check-if-filtered-cells-contain-data-delete.html)

Les Stout[_2_]

Check if filtered cells contain data to delete
 
Hi all, I need a bit of help with code for the following. I am filtering
a column for certain criteria and i need to check if the other cells in
the filtered visual cells contain data, if no data continue with code
else delete rows visable only.

Selection.AutoFilter Field:=9, Criteria1:="=*za-t-m-**", Operator:=xlAnd


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Dave Peterson

Check if filtered cells contain data to delete
 
With Worksheets("sheet1")
If .AutoFilter.Range.Columns(1).Cells.SpecialCells(xl CellTypeVisible) _
.Count = 1 Then
'Only headers
MsgBox "nothing to delete"
Else
With .AutoFilter.Range
.Resize(.Rows.Count - 1).Offset(1, 0).EntireRow.Delete
End With
End If
End With


Les Stout wrote:

Hi all, I need a bit of help with code for the following. I am filtering
a column for certain criteria and i need to check if the other cells in
the filtered visual cells contain data, if no data continue with code
else delete rows visable only.

Selection.AutoFilter Field:=9, Criteria1:="=*za-t-m-**", Operator:=xlAnd

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson

Les Stout[_2_]

Check if filtered cells contain data to delete
 
Thanks a lot Dave,

I will give it a bash in the morning and let you know..

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Les Stout[_2_]

Check if filtered cells contain data to delete
 
Thank you Dave Peterson, your solution worked 100%, thanks.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 10:36 AM.

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