Excel 切片器修改属性
尝试使用VBA生成透视表和关联切片器。我能够很好地生成表和切片器,但是当我试图修改切片器属性时,我得到了错误5。错误在“With”行中。我现在有什么错 试图将名称值更改为实际切片器装运数量。并在网上四处查看,但我没有看到任何解决方案。我确实从这个网站上找到了一个,但是,当我使用它/键入复制它时,它似乎不起作用Excel 切片器修改属性,excel,vba,Excel,Vba,尝试使用VBA生成透视表和关联切片器。我能够很好地生成表和切片器,但是当我试图修改切片器属性时,我得到了错误5。错误在“With”行中。我现在有什么错 试图将名称值更改为实际切片器装运数量。并在网上四处查看,但我没有看到任何解决方案。我确实从这个网站上找到了一个,但是,当我使用它/键入复制它时,它似乎不起作用 'This works to create slicer ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("MasterP
'This works to create slicer
ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("MasterPivot"), "ShipQuantity") _
.Slicers.Add ActiveSheet, , "ShipQuantity", "ShipQuantity", _
RowLocation, ColumnLocation, width, Height
'this does not work to modify slicer settings. And I have no idea why.
With ActiveWorkbook.SlicerCaches("ShipQuantity").Slicers("ShipQuantity")
.NumberOfColumns = 3
.RowHeight = 13
.ColumnWidth = 70
End With
希望代码能够修改显示的切片器,而不会出现任何错误。请,谢谢
切片器。Add
返回对添加切片器的引用,因此您可以直接使用该引用
Dim slcr
Set slcr = ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("MasterPivot"), "ShipQuantity") _
.Slicers.Add(ActiveSheet, , "ShipQuantity", "ShipQuantity", _
RowLocation, ColumnLocation, width, Height)
With slcr
.NumberOfColumns = 3
.RowHeight = 13
.ColumnWidth = 70
End With