我不希望我的 VBA 代码更改工作表
I do not want my VBA code to change sheets
因此,每次在主 sheet(仪表板)中进行更改时,我都尝试使用代码简单地刷新数据透视表 Table。
因为我需要保持清洁,所以我有另一个 sheet,所有信息都在这里,名为 historic_var
。
问题是,当我 运行 代码时,它运行良好,但它变成了没有用的 sheet(除非保持信息安全)。我能做些什么?已经试过了application.ScreenUpdating = False
当前代码为:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <= 14 Then
Sheets("historic_var").Select
ActiveSheet.PivotTables("Tabela dinâmica1").PivotCache.Refresh
End If
End Sub
您可以在不更改 sheet 的情况下更新 table。试试这个...
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <= 14 Then
Sheets("historic_var").PivotTables("Tabela dinâmica1").PivotCache.Refresh
End If
End Sub
因此,每次在主 sheet(仪表板)中进行更改时,我都尝试使用代码简单地刷新数据透视表 Table。
因为我需要保持清洁,所以我有另一个 sheet,所有信息都在这里,名为 historic_var
。
问题是,当我 运行 代码时,它运行良好,但它变成了没有用的 sheet(除非保持信息安全)。我能做些什么?已经试过了application.ScreenUpdating = False
当前代码为:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <= 14 Then
Sheets("historic_var").Select
ActiveSheet.PivotTables("Tabela dinâmica1").PivotCache.Refresh
End If
End Sub
您可以在不更改 sheet 的情况下更新 table。试试这个...
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <= 14 Then
Sheets("historic_var").PivotTables("Tabela dinâmica1").PivotCache.Refresh
End If
End Sub