在下面的行(pi.Visible = False)下,当我们尝试运行报告时,这会不断记录调试错误。
Set pt = Worksheets ("Design Type of Work") .PivotTables("PivotTable1")
Set pf = pt.PivotFields ("Date Design Sent for Builder Approval")
pt.ManualUpdate = True
For Each pi In pf.PivotItems
If Left(pi, 4) = thisyr Then
pi.Visible = True
Else
pi.Visible = False
End If
Next pi
pt.ManualUpdate = False
End Sub