VBA for slicer

nrfixter

New Member
Joined
Apr 20, 2017
Messages
2
Hi all,

I've got a 'Summary' worksheet with a number of slicers and on a different sheet (called 'Risks') I have a macro that creates a new slicer on the 'Summary' sheet based on the name entered in a specific cell and sizes and places it according to numbers entered in specific cells. The issue is that when the new slicer is made, one of the default properties is to 'move but don't size with cells' and I want to make it 'don't move or size with cells'.

I know how to do this manually but don't know how to add the VBA code for doing it to the bottom of my existing 'Create slicer' macro:

Sheets("Summary").Activate
slicer_name = Sheets("Risks").Range("Risk_Type").Value

ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("PivotTable2"), slicer_name).Slicers.Add ActiveSheet, , slicer_name, slicer_name, Sheets("Risks").Range("Slc_Vrt").Value, Sheets("Risks").Range("Slc_Hzt").Value, Sheets("Risks").Range("Slc_Width").Value, Sheets("Risks").Range("Slc_Height").Value

Any help would be greatly appreciated.

Thanks,

N
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Will answer my own question in case anyone needs to know:

slicer_title = Sheets("Risks").Range("Risk_Type")

Sheets("Summary").Select
ActiveSheet.Shapes.Range(Array(slicer_title)).Select
Selection.Placement = xlFreeFloating

If you wanted to make it move and size with cells you just replace the 'xlFreeFloating' part with 'xlMoveAndSize'
 
Upvote 0

Forum statistics

Threads
1,215,581
Messages
6,125,656
Members
449,246
Latest member
jbbtz28

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