gpt4 book ai didi

VBA 我无法使用 Dictionary 来使用 Exists 方法

转载 作者:行者123 更新时间:2023-12-02 12:09:17 25 4
gpt4 key购买 nike

pivot table

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

关于VBA 我无法使用 Dictionary 来使用 Exists 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41688046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com