If you're experiencing an issue with your macro failing after using the AutoFilter function in Excel, there are a few things you can try to troubleshoot the problem.
When you run into an issue with your macro code, the first thing you should always do is check for any errors. If there are any syntax errors or other problems with your code, the macro will usually fail when it reaches that point. To check your code for errors:
If there are any errors in your code, they will be listed in the Compile Error window. Fix any errors that are listed and try running your macro again.
Sometimes, the issue can be caused by something in the workbook that's causing problems. To rule this out, try running your macro in a new, blank workbook. If it works fine in a new workbook, then there's probably something wrong with the original workbook that's causing the problem.
If AutoFilter is turned on when your macro runs, it can cause problems. To make sure AutoFilter is turned off before running your macro:
(If "AutoFilter" isn't listed as an option, then it's already turned off and you don't need to worry about this.)
Once you've tried all of these troubleshooting steps, hopefully your macro will start working correctly again!