我现在有这些代码集。我如何对其进行编码,以便它将复制的值粘贴到数据透视表工作表中的最后一行下面的值中。就像它遍历第一个切片并将值粘贴到数据透视表工作表的A列中一样。它遍历第二个切片,复制并粘贴从最后一个单元格开始的值以及切片器1的值。而且除了For CurrentSlice = 1 To 20
之外,还有一种方法可以让我遍历所有切片器选项而没有范围吗?
Sub IterateSlices()
Dim CurrentSlice As Integer
ActiveSheet.Name = "BSC"
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = "PivotTable"
For CurrentSlice = 1 To 20
SelectOnly ActiveWorkbook.SlicerCaches("Slicer_Engine_S_N."),
CurrentSlice
Sheets("BSC").Select
Columns(2).EntireColumn.Select
Selection.copy
Sheets("PivotTable").Select
Range("A1").Select
ActiveSheet.Paste
Columns("A:A").EntireColumn.EntireColumn.AutoFit
Next
End Sub
Sub SelectOnly(Slicer As SlicerCache, SliceNo As Integer)
Dim i As Integer
' Force at least one to be selected before start
Slicer.SlicerItems(Slicer.SlicerItems.Count).Selected = True
For i = 1 To Slicer.SlicerItems.Count
Debug.Print (SliceNo = i)
Slicer.SlicerItems(i).Selected = (SliceNo = i)
Next i
End Sub