我什至不确定这是否可能。但我使用的是一个非常庞大的数据表,主要由切片器控制。当我提取此数据表时,我希望在标题中包含切片器的设置和提取的日期/时间(作为对切片器正确设置的额外确认,当然还有提取数据的时间点)。
谷歌不知道答案,因为我的 google-fu 往往很强大,所以我来这里寻求建议。
这甚至可能吗?最好在 VBA 中进行。
我什至不确定这是否可能。但我使用的是一个非常庞大的数据表,主要由切片器控制。当我提取此数据表时,我希望在标题中包含切片器的设置和提取的日期/时间(作为对切片器正确设置的额外确认,当然还有提取数据的时间点)。
谷歌不知道答案,因为我的 google-fu 往往很强大,所以我来这里寻求建议。
这甚至可能吗?最好在 VBA 中进行。
啊找到了。
使用下面的代码创建了一个 PublicFunction,它将显示选定的切片器值。
Public Function GetSelectedSlicerItems(SlicerName As String) As String
Dim oSc As SlicerCache
Dim oSi As SlicerItem
Dim lCt As Long
On Error Resume Next
Application.Volatile
Set oSc = ThisWorkbook.SlicerCaches(SlicerName)
If Not oSc Is Nothing Then
For Each oSi In oSc.SlicerItems
If oSi.Selected Then
GetSelectedSlicerItems = GetSelectedSlicerItems & oSi.Name & ", "
lCt = lCt + 1
ElseIf oSi.HasData = False Then
lCt = lCt + 1
End If
Next
If Len(GetSelectedSlicerItems) > 0 Then
If lCt = oSc.SlicerItems.Count Then
GetSelectedSlicerItems = "All"
Else
GetSelectedSlicerItems = Left(GetSelectedSlicerItems, Len(GetSelectedSlicerItems) - 2)
End If
Else
GetSelectedSlicerItems = "No items selected"
End If
Else
GetSelectedSlicerItems = "No slicer with name '" & SlicerName & "' was found"
End If
End Function