I am using Excel 2007. I created a macro today to hide all the rows in a spreadsheet that contain a zero value in them. However, the first time I run the macro I get this run time error. If I click "end" and then push the macro button again, it runs fine - no debugging necessary. Any ideas how I get the error message to stop popping up? My macro is as follows (and yes, it is filtering through over 5000 rows):
Sub AutoHide()
'
' AutoHide Macro
' Automatically hide rows with a 0 value.
'
' Keyboard Shortcut: Ctrl+h
'
Selection.AutoFilter
ActiveSheet.Range("$A$3:$J$5071").AutoFilter Field:=10, Criteria1:=">0", _
Operator:=xlAnd
End Sub
The section in red is what it is hilighting telling me is what is wrong when I click on debug. Again, I don't have to make any changes to anything, just go back to the button and click it again, and it runs fine. Does it matter that I made my spreadsheet a template? It seems like that is when I started getting this error, but I could be wrong.
Thank you!
Sub AutoHide()
'
' AutoHide Macro
' Automatically hide rows with a 0 value.
'
' Keyboard Shortcut: Ctrl+h
'
Selection.AutoFilter
ActiveSheet.Range("$A$3:$J$5071").AutoFilter Field:=10, Criteria1:=">0", _
Operator:=xlAnd
End Sub
The section in red is what it is hilighting telling me is what is wrong when I click on debug. Again, I don't have to make any changes to anything, just go back to the button and click it again, and it runs fine. Does it matter that I made my spreadsheet a template? It seems like that is when I started getting this error, but I could be wrong.
Thank you!