custom auto filter

  • Thread starter Thread starter Ranjit kurian
  • Start date Start date
R

Ranjit kurian

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top