I am very new to Visual Basic and writing macros. I tried to record a macro, where I clicked on the worksheet, "Q1 - Pivot Table", that has the originating data that I want to copy, which is a pivot table. I then did a copy of "all cells", then I clicked on the other destination worksheet, "Q1 Pivot Report", and paste all the data, and then stop the recording of the macro. The Q1 Pivot Report worksheet does have all the data and formatting correctly. I then go into the macro I just recorded and copy-n-paste the programming into a COMMAND BUTTON that I have created called "Q1", and I save it. When I click the Q1 command button to run this macro, I get an error: "Run-time error '1004': Select method of Range class failed". When I click to "debug", the programming for that command button comes up and has the line, "Range ("A1").Select" is highlighted in yellow. Below is a copy of the programming that I recorded and I am trying to use for this command button. It seems that it would be a simple copy-n-paste, taking all the data on one worksheet and copying it into another worksheet. I just cannot figure why it is not working. I know it's probably something very simple.
[B]Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Refresh and copy Q1 Pivot Table to Q1 PIVOT REPORT
'
'Select the filtered data and copy it
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Q1 - PIVOT Table").Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Q1 PIVOT REPORT").Activate
Range("A1").Select
Selection.PasteSpecial
ActiveSheet.Range("A1").Select
'
End Sub
If someone can please help me out with this simple macro, I would greatly appreciate it. Regards.
Bookmarks