+ Reply to Thread
Results 1 to 4 of 4

Runtime error 1004 - Autofilter method of range class failed

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question Runtime error 1004 - Autofilter method of range class failed

    Hi All

    I have a workbook with 3 sheets - Employees, Covid Tests, Anti-Body Tests

    I've added some activex text boxes to the Employees sheet so that the end user can search/filter the list as they type

    Sheet1 - This code works fine
    Please Login or Register  to view this content.
    But then I've tried to implement a similar thing on the 2 remaining sheets for test results, so that when the employees table is filtered to a single employee, their ID number is carried through to the test results sheets and these sheets will then also filter to only show results for that one person

    But I'm getting a run time error on the 2nd line when using this code on sheet3 and sheet4

    vba.png

    Run time 1004.png

    I think the problem lies with what sheet is active.
    If the code on sheet3 or sheet4 is triggered while sheet1 (Employees table) is active, it produces the run time error

    But if I'm on sheet3 or sheet4 and trigger the code manually (by typing numbers in cell C3) the code executes no problem

    Is there any way to get around this?

    Many thanks in advance
    Vicky
    Attached Files Attached Files
    Last edited by vwhite; 01-20-2021 at 09:20 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Runtime error 1004 - Autofilter method of range class failed

    How are you changing the contents of a textbox on a different sheet to the active one?
    Rory

  3. #3
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Runtime error 1004 - Autofilter method of range class failed

    Hi Rory

    Hope you are well

    In sheet3 & sheet4 cell C3 contains a formula that says 'when sheet1 is filtered to only 1 visible employee, grab the emp ID in cell sheet1.C9 and pull it through'

    =IF(Employees!$L$1=1,Employees!$C$9,"")

    I've then placed a textbox box over the top that's linked to cell C3 so they'll display the result & trigger the vba

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Runtime error 1004 - Autofilter method of range class failed

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

+ 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. Runtime error 1004 - PasteSpecial method of Range class failed
    By Ruthie09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2016, 08:17 PM
  2. Runtime error '1004' - Autofilter method of Range class failed
    By penfolda in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2014, 12:04 PM
  3. [SOLVED] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  4. Runtime error 1004: Insert method of Range class failed......not sure why
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-21-2011, 02:15 PM
  5. runtime error 1004 pastespecial method of range class failed
    By JillCALIBRE in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-30-2009, 11:31 AM
  6. runtime error 1004 pastespecial method of range class failed
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2006, 10:57 AM
  7. [SOLVED] Runtime Error 1004 Select method of Range class Failed
    By IanO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2005, 04:05 PM

Tags for this Thread

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