Martin_H
Board Regular
- Joined
- Aug 26, 2020
- Messages
- 190
- Office Version
- 365
- Platform
- Windows
Hi,
I am using this part of code (see below) to create multiple slicers (only 2 are shown here) for my pivot chart.
I have been wondering if it is possible to simplify/merge the code.
Thank you for help.
I am using this part of code (see below) to create multiple slicers (only 2 are shown here) for my pivot chart.
I have been wondering if it is possible to simplify/merge the code.
Thank you for help.
VBA Code:
Dim SLcache As SlicerCache
Dim SL As SLICER
Dim wb As Workbook
Set wb = ActiveWorkbook
'Slicer Date
Set SLcache = wb.SlicerCaches.Add2(pt, "Date", "Date_May")
Set SL = SLcache.SLICERS.Add(ws, , "Date_May", "Date", 0, 0, 100, 150)
With SL
.Top = 30: .Left = 100: .Style = "SlicerStyleLight4": .RowHeight = 15: .ColumnWidth = 80
End With
'Slicer Machine
Set SLcache = wb.SlicerCaches.Add2(pt, "Machine", "Machine_May")
Set SL = SLcache.SLICERS.Add(ws, , "Machine_May", "Machine", 0, 0, 100, 150)
With SL
.Top = 30: .Left = 216: .Style = "SlicerStyleLight1": .RowHeight = 15: .ColumnWidth = 80
End With