刷新枢轴不出现错误
Refresh pivots doenst appear error
这是我的代码:
Sub Atualiza_pivots()
ActiveWorkbook.RefreshAll
End Sub
我用简单的代码刷新了工作簿中的所有数据透视表,但是如果某些数据透视表确实刷新了,我没有看到它,所以,我不知道它什么时候出错。我尝试制作另一个代码,但它一直没有出现。
Sub Atualiza_pivots()
On Error GoTo Err
ActiveWorkbook.RefreshAll
Exit Sub
Err: MsgBox "Há pivots com erro, verifique."
End Sub
谢谢。
RefreshAll 方法仅在 BackgroundQuery 设置为 True 时有效,尝试循环遍历每个 table 并手动刷新它:
Sub Refresher()
Dim wks As Worksheet
Dim pvt As PivotTable
For Each wks In Worksheets
For Each pvt In wks.PivotTables
If pvt.PivotCache.BackgroundQuery = False Then
pvt.PivotCache.BackgroundQuery = True
pvt.RefreshTable
pvt.PivotCache.BackgroundQuery = False
Else
pvt.RefreshTable
End If
Next pvt
Next wks
End Sub
感谢帮助D_Zab
Sub Atualiza_pivots()
Dim wks As Worksheet
Dim pvt As PivotTable
For Each wks In Worksheets
For Each pvt In wks.PivotTables
On Error GoTo Err
pvt.PivotCache.Refresh
Next pvt
Next wks
Exit Sub
Err: MsgBox pvt & " com erro."
End Sub
这是我的代码:
Sub Atualiza_pivots()
ActiveWorkbook.RefreshAll
End Sub
我用简单的代码刷新了工作簿中的所有数据透视表,但是如果某些数据透视表确实刷新了,我没有看到它,所以,我不知道它什么时候出错。我尝试制作另一个代码,但它一直没有出现。
Sub Atualiza_pivots()
On Error GoTo Err
ActiveWorkbook.RefreshAll
Exit Sub
Err: MsgBox "Há pivots com erro, verifique."
End Sub
谢谢。
RefreshAll 方法仅在 BackgroundQuery 设置为 True 时有效,尝试循环遍历每个 table 并手动刷新它:
Sub Refresher()
Dim wks As Worksheet
Dim pvt As PivotTable
For Each wks In Worksheets
For Each pvt In wks.PivotTables
If pvt.PivotCache.BackgroundQuery = False Then
pvt.PivotCache.BackgroundQuery = True
pvt.RefreshTable
pvt.PivotCache.BackgroundQuery = False
Else
pvt.RefreshTable
End If
Next pvt
Next wks
End Sub
感谢帮助D_Zab
Sub Atualiza_pivots()
Dim wks As Worksheet
Dim pvt As PivotTable
For Each wks In Worksheets
For Each pvt In wks.PivotTables
On Error GoTo Err
pvt.PivotCache.Refresh
Next pvt
Next wks
Exit Sub
Err: MsgBox pvt & " com erro."
End Sub