VBA PowerPivot Slicer Left Position Incorrect

goss

Active Member
Joined
Feb 2, 2004
Messages
372
Hi all,

Using Excel 2010

I am trying to add a slicer dynamically.
User chooses from another slicer, Pivot Table is updated, should delete and recreate another slicer

Works well excel the left position of the slicer
I have noted to position at 1202.75. However it is consistently positioned at 1207.25

Any thoughts on why this may be?

thx
w

Code:
'Add slicer cache
        With wb
            .SlicerCaches.Add(wsPT.PivotTables("PivotTable1"), _
            "[dimTable].[Field]").Slicers.Add ws, _
            "[dimTable].[Field].[Field]", "Field", "Field", 481.75, _
            1202.75, 158.5001, 198.75
        End With

Code to test Slicer:
Code:
Sub SlicerProperties()

    Dim wb As Workbook
    Dim ws As Worksheet
    Dim sh As Shape
    
    Set wb = ThisWorkbook
    Set ws = wb.Worksheets("Scorecard")
    
    With ws
        For Each sh In .Shapes
            If sh.Type = msoSlicer Then
                Debug.Print "Name " & sh.Name
                Debug.Print "Type " & sh.Type
                Debug.Print "Width " & sh.Width
                Debug.Print "Top " & sh.Top
                Debug.Print "Left " & sh.Left
                Debug.Print "Height " & sh.Height
                Debug.Print "-----------------------------------"
            End If
        Next sh
    End With
    
    Set ws = Nothing
    Set wb = Nothing

End Sub

Output:
Name SlicerName
Type 25
Width 159.2501
Top 481.75
Left 1207.25
Height 198.75
-----------------------------------
 

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

Forum statistics

Threads
1,223,966
Messages
6,175,662
Members
452,666
Latest member
AllexDee

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