I'm trying to run some very simple code to clear out a table on one tab, then filter a table on another tab and copy the filtered data back to the table I just cleared. This all works wonderfully if I simply execute the macro. However, if I then paste the code into the Private Sub for an ActiveX button control, it fails with message "Runtime error '1004' Method 'Range' of object '_Worksheet' failed. it does so at the "Range("Table13").Select" line.
I an SURE there a much more elegant way to do this and I'm happy to see the suggestions. But could someone explain to me what is happening? How could something so simple not work just because it is being called from a button? I'd really like to understand this. Thanks!
I an SURE there a much more elegant way to do this and I'm happy to see the suggestions. But could someone explain to me what is happening? How could something so simple not work just because it is being called from a button? I'd really like to understand this. Thanks!
Code:
' Clear the Additional Tabs
Sheets("RptSheet").Select
Range("Table13").Select
Selection.ClearContents
' Filter Copy to Tab
Sheets("Query").Select
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=14, Criteria1:= _
"="
Range("Table1").Select
Selection.Copy
Sheets("RptSheet").Select
Range("A2").Select
ActiveSheet.Paste