ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   custom auto filter (https://www.excelbanter.com/excel-programming/416090-custom-auto-filter.html)

Ranjit kurian

custom auto filter
 
Hi

When i do Custome autofillter for 'Mon' in Month Column, and if 'Mon' is not
found then exit sub if found then copy the entire sheet.


example:
Month
Mon
Tue
Wed
Mon




Bob Phillips[_3_]

custom auto filter
 
Dim rng As Range
Dim LastRow As Long

Columns(1).AutoFilter
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A1").Resize(LastRow)
rng.AutoFilter field:=1, Criteria1:="Mon"
On Error Resume Next
Set rng = rng.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If rng.Rows.Count 1 Then

Cells.Copy
'do something with it
End If

rng.AutoFilter


--
__________________________________
HTH

Bob

"Ranjit kurian" wrote in message
...
Hi

When i do Custome autofillter for 'Mon' in Month Column, and if 'Mon' is
not
found then exit sub if found then copy the entire sheet.


example:
Month
Mon
Tue
Wed
Mon







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

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