VBA我不能使用Dictionary的Exists方法

数据透视表

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方法来排除项目​​。 你能给我build议吗?

形成针对该问题发表的评论:

修剪数据透视表中的值,使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