+ Reply to Thread
Results 1 to 3 of 3

If Autofilter Criteria doesn't return a field, how can I re-direct it to do something else

  1. #1
    Registered User
    Join Date
    09-28-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    If Autofilter Criteria doesn't return a field, how can I re-direct it to do something else

    Hi,

    I've got the following codes which filter for the "adj" in the "total" page and copy the results to the "sum" page. It then goes back to the "main" page where the instructions sit.
    However, the "adj" field is not there all the time.
    Would you know how can I get the macro to do the "copy and paste" if the "adj" field is there but when "adj" is unavailable; directs it back to the "main" page?
    Thanks.


    Sheets("total").Select
    Cells.Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=19, Criteria1:="=ADJ"

    Range("W1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy

    Sheets("sum").Select
    Range("A1").Select
    ActiveSheet.Paste

    Sheets("main").Select
    Range("A1").Select

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: If Autofilter Criteria doesn't return a field, how can I re-direct it to do something

    Please Login or Register  to view this content.


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: If Autofilter Criteria doesn't return a field, how can I re-direct it to do something

    Hi, tlo_123,

    please wrap your code with code-tags.

    Get the last visible row in the column you set the filter which should be greater than the row for the header (code is untested):
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 09-28-2013 at 03:43 PM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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. AutoFilter doesn't always return value set as default
    By mhelberg in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-09-2013, 10:55 PM
  2. Replies: 4
    Last Post: 03-16-2013, 08:33 AM
  3. [SOLVED] Autofilter - Macro to Return Value in Userform Field based upon Most Recent Date
    By Southfish in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-01-2012, 12:57 AM
  4. What if criteria doesn't exist for autofilter?
    By brandoncurrey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2011, 05:31 PM
  5. [SOLVED] ADO cloned recordset doesn't return field names
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2005, 06:06 PM

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