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

cmcamilo

New Member
Joined
Dec 19, 2022
Messages
11
Office Version
  1. 365
Platform
  1. Windows
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:
VBA 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.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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.
1671469449640.png

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.
1671469346704.png
 
Upvote 0
Solution
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!
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.
View attachment 81203
When I copy & paste from one workbook to another I get this message:

slicer error.png

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.
 
Upvote 0
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 Worksheets, not Workbooks. 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.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top