+ Reply to Thread
Results 1 to 3 of 3

If auto filter do not returns results to move to next filter criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    11-18-2021
    Location
    Frankfurt
    MS-Off Ver
    2019
    Posts
    6

    If auto filter do not returns results to move to next filter criteria

    Hi, I have seen similar posts to this, but cannot figure out how it can relate to my situation. I have an auto filter that copies data from one sheet to another. However, when no auto filter results are listed, I would like it to skip the copying steps and go on to the next auto filter criteria.


    HTML Code: 
    Thanks in advance for your help!

  2. #2
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,175

    Re: If auto filter do not returns results to move to next filter criteria

    Might be enough to evaluate the number of visible rows.

    '...
    Selection.AutoFilter Field:=1, Criteria1:="=*" & Range("J1").Value & "*", Operator:=xlOr, _
    Criteria2:="=*" & Range("K1").Value & "*"
    
    If AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count -1 >0 then '-1 to discount the header row
    
    Cells.Select
    Selection.Copy
    Sheets.Add After:=ActiveSheet
    ActiveSheet.Paste
    Sheets("Data)").Select
    Selection.AutoFilter
    Sheets("Client").Select
    ActiveCell.Offset(1, 0).Range("A1:B1").Select
    
    End If
    
    Next i
    Else
    MsgBox "Please enter a number!", vbInformation
    GoTo Anf
    End If

  3. #3
    Registered User
    Join Date
    11-18-2021
    Location
    Frankfurt
    MS-Off Ver
    2019
    Posts
    6

    Re: If auto filter do not returns results to move to next filter criteria

    Hi ByteMarks, Thank you very much for your response. I got the error message at the Range location stating that the argument is not optional. What is wrong? I then tried it without Range. But the macro stops after the first search.

    If AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count -1 >0 then

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Next
    By cvici in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2021, 11:20 AM
  2. [SOLVED] Auto Filter and Sum Results (Material Filter and Optimser)
    By Ross82 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-10-2019, 12:07 AM
  3. Different results for Auto Filter and Advanced Filter
    By me20161130 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2016, 09:02 AM
  4. [SOLVED] Loop through Auto Filter Criteria and Copy Formula Results Into New Sheet
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-21-2014, 05:34 PM
  5. Advanced Filter : One Criteria Cell Breaks the Filter - Returns Only Headers
    By PaulGW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-28-2014, 10:06 AM
  6. [SOLVED] Advanced Filter results don't match auto filter
    By WaterWings in forum Excel General
    Replies: 1
    Last Post: 09-13-2012, 05:37 PM
  7. Auto Filter returns no results
    By terrapinie in forum Excel General
    Replies: 2
    Last Post: 01-07-2006, 04:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1