excel 为什么我尝试透视筛选时会出现“对象不支持此属性或方法”错误?

qrjkbowd  于 2023-01-03  发布在  其他
关注(0)|答案(1)|浏览(148)
Dim datasheet As Worksheet
Dim PT As PivotTable
Dim field As PivotField

Set datasheet = Sheets(1)

Set PT = datasheet.PivotTables("PivotTable2")
Set field = PT.PivotFields("Chapter_Desc")

field.ClearAllFilters
field.datasheet = "Georgia"

Set field = Nothing
Set PT = Nothing

我期望这将透视字段Chapter_Desc过滤为Georgia
相反,它在field.datasheet = "Georgia行给予我一个错误
对象不支持此属性或方法。

6xfqseft

6xfqseft1#

试试看

Dim f As PivotItem
    For Each f In field.PivotItems
        If f.Name = "Geogia" Then
            f.Visible = True
        Else
            f.Visible = False
        End If
    Next

相关问题