+ Reply to Thread
Results 1 to 5 of 5

Error when triggering a macro to clear filtered data

  1. #1
    Registered User
    Join Date
    09-12-2008
    Location
    Riversul
    MS-Off Ver
    2016
    Posts
    83

    Error when triggering a macro to clear filtered data

    Hello folks, how's going? So I created this sheet that is meant to work as a database, and another one, which has this header and works as a filter. I came up with a macro that will automatically trigger the filter event when a criteria is selected, and if all the criteria spaces are blank, it erases all the data that it was previously filtered. That VBA code worked fine for me at the Excel 2013, but it's not working properly at the Excel 2016 (I'm getting an error message at the "If Application.WorksheetFunction.CountA(Range("$D$4:$H$4")) = 0 Then"). Is there any alternative that could use to achieve that same result? Thanks in advance (present code below):


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Error when triggering a macro to clear filtered data

    Hi.
    What's the error you get?
    Could it be your "ClearData" kicking in the worksheet_Change event?

  3. #3
    Registered User
    Join Date
    09-12-2008
    Location
    Riversul
    MS-Off Ver
    2016
    Posts
    83

    Re: Error when triggering a macro to clear filtered data

    Hello Dave, thank you for your reply! The message I'm getting is "Error 28: Out of stack space". Another error that I'm getting is "The Clear method of the Range object has failed" (when I tried to clear a different field of the header)

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Error when triggering a macro to clear filtered data

    Maybe the following code before all the other code.
    Please Login or Register  to view this content.
    You could be getting an error because there is more than one cell being changed at once. The Target.count code stops this from happening, if there is more than one item being changed at once, the line of code will exit the sub.

    You did not supply the other codes so I have no opinion on them.

  5. #5
    Registered User
    Join Date
    09-12-2008
    Location
    Riversul
    MS-Off Ver
    2016
    Posts
    83

    Re: Error when triggering a macro to clear filtered data

    Hello again, Dave! I tried that code you've sent me and it has worked out just fine, thank you very much for your assistance!

+ 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. [SOLVED] Clear contents of every second row from filtered data
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2017, 06:59 AM
  2. clear entier cells on filtered data
    By hudson andrew in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2016, 03:12 PM
  3. [SOLVED] error 400 when running macro to clear data
    By majime01 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2015, 04:39 PM
  4. [SOLVED] Error on macro to clear filters
    By acroley1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-26-2015, 01:58 PM
  5. Replies: 1
    Last Post: 06-21-2013, 04:05 AM
  6. Print Macro / module error & Update / Clear Macro error
    By mal.b.graham in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-28-2012, 06:40 PM
  7. Macro to clear error
    By gifer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-09-2005, 11:06 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