excel - VBA我无法使用字典存在方法-LMLPHP

Dim memberDic As Object: Set memberDic = CreateObject("Scripting.Dictionary")
Set memberDic("Team A") = CreateObject("Scripting.Dictionary")

memberDic("Team A")("Tanaka") = 1
memberDic("Team A")("Watanabe") = 2
memberDic("Team A")("Shimizu") = 3

For Each person In ActiveSheet.PivotTables(fy).PivotFields("name").PivotItems
    If Not memberDic("Team A").Exists(person.Name) Then
        'hidden person except Team A
    End If
Next person

我想使用Exists方法排除项目。
你能给我建议吗?

最佳答案

正式发布针对该问题的评论:

修剪数据透视表中的值,以使Exists正常工作:

For Each person In ActiveSheet.PivotTables(fy).PivotFields("name").PivotItems
    If Not memberDic("Team A").Exists(Trim(person.Name)) Then
        'hidden person except Team A
    End If
Next person

08-05 15:06