# Is there a way to copy and paste slicers from one worksheet to another?



## cmcamilo (Dec 19, 2022)

Hello,

I have a worksheet that has two charts with two slicers that filters data in those charts. 
I was trying to copy and paste both the charts and the slicers to a new worksheet through a button.
I have this code:

```
Private Sub CommandButton1_Click()

Workbooks("original_worksheet.xlsx").Worksheets("Chart").Range("A1:AB39").Copy
Sheets("new_worksheet").Activate
Range("A4").Select

ActiveSheet.Paste

Application.CutCopyMode = False

End Sub
```

But it only copies the charts and not the slicers. The slicers in the original worksheet still filter the data from the charts that were pasted into the new worksheet, but I would like to have them in this new worksheet.
I know that manually we can't copy and paste slicers, but isn't there a way to do it with VBA?
I have searched everywhere and haven't found anything.

Thank you.


----------



## jdellasala (Dec 19, 2022)

If you select the slicer (make sure the selection circles are there to move it/change the size) and hit *Ctrl-C* to copy (or use *Copy* from the Home tab), go to another worksheet and hit *Ctrl-V* (or Paste) the slicer will be copied.




Make sure the active cell is in a blank area of the Worksheet, or it can overwrite what's there. 
This *assumes* the Pivot Tables are using the same Data Source (under *Pivot Table Analyze -> Change Data Source*) OR is using a common data source like a Calendar Table, or it would be useless on another sheet!
However, to have it control the PT on the new worksheet, you will need to Right Click on it and select *Report Connections* and check the boxes for the PTs you want to be filtered by the Slicer.


----------



## cmcamilo (Dec 20, 2022)

jdellasala said:


> If you select the slicer (make sure the selection circles are there to move it/change the size) and hit *Ctrl-C* to copy (or use *Copy* from the Home tab), go to another worksheet and hit *Ctrl-V* (or Paste) the slicer will be copied.
> View attachment 81204
> Make sure the active cell is in a blank area of the Worksheet, or it can overwrite what's there.
> This *assumes* the Pivot Tables are using the same Data Source (under *Pivot Table Analyze -> Change Data Source*) OR is using a common data source like a Calendar Table, or it would be useless on another sheet!
> ...


When I copy & paste from one workbook to another I get this message:




It only works when the sheets are from the same workbook, right? That I already did and works perfectly. But I needed it to be copied to another workbook. For the research I have done I don't think it's posible.


----------



## jdellasala (Dec 20, 2022)

cmcamilo said:


> When I copy & paste from one workbook to another I get this message:
> 
> View attachment 81248
> It only works when the sheets are from the same workbook, right? That I already did and works perfectly. But I needed it to be copied to another workbook. For the research I have done I don't think it's posible.


Your initial post indicated copying between Work*sheets*, not Work*books*. As you've found, you can't get a workbook to be filtered by a slicer in another workbook. It makes sense. The Pivot Cache and underlying data are not available in the second Workbook.


----------

