我正在尝试将一个切片器添加到数据透视表中。我正在从数据透视表中成功创建切片器缓存,但切片器本身会挂起运行时错误483(对象不支持此属性或方法)或运行时错误5(无效的过程调用或参数) )。后者发生在以下代码配置中。行t(apply(df2, 1, function(x) abs(x - df1[1,])))
Set slicer = .Slicers.Add(pvt, , "Date", "date", 200, 250, 200, 200)
答案 0 :(得分:1)
Slicers.Add Method (Excel)
语法是:
expression.Add(SlicerDestination, Level, Name, Caption, Top, Left, Width, Height)
PivotTable
SlicerDestination
替换这些行:
With wb
Set SlcCache = .SlicerCaches.Add2(Pvt, "Date", "Date", xlTimeline)
With SlcCache
Set Slicer = .Slicers.Add(Pvt, , "Date", "date", 200, 250, 200, 200)
End With
With PvtWs
.Shapes.Range(Array("Date")).Select
End With
End With
这些行:
Set SlcCache = wb.SlicerCaches.Add2(Pvt, "Date", "Date", xlTimeline)
Set Slicer = SlcCache.Slicers.Add(PvtWs, , "Date", "date", 200, 250, 200, 200)
PvtWs.Shapes.Range(Array("Date")).Select