excel - 更新它所基于的数据透视表和链接表的问题
问题描述
我有一个链接到经常更新的 Access 数据库的表。该表用于填充数据透视表。
我有按下刷新按钮时执行的以下宏。问题是选择此按钮时,链接表被刷新,但是要刷新枢轴表,我必须在链接的表格完成新数据刷新后再次按下按钮。
我应该等到使用 VBA 刷新链接表并在之后刷新数据透视表吗?如何才能做到这一点:
当前宏:
Sub RefreshFunc()
ThisWorkbook.RefreshAll
End Sub
解决方案
尝试这个...
Sub ChangeConnectionRefreshModeAndRefreshAll()
'-------------------------------------------------------------------------------------
' Purpose: Turn off background refreshing for all workbook connections.
' This prevents hangs and crashes. Cycle 2x
'
' Source: https://www.myonlinetraininghub.com/excel-forum/vba-macros/pause-macro-until-power-queries-finished-refreshing
'
' Revisions
' 01/30/19
'-------------------------------------------------------------------------------------
Dim Connection As WorkbookConnection
Dim bugfix As Integer
For bugfix = 1 To 2
On Error Resume Next
For Each Connection In ActiveWorkbook.Connections
With Connection
If (.Type = xlConnectionTypeODBC) Then
.ODBCConnection.BackgroundQuery = False
Else
If (.Type = xlConnectionTypeOLEDB) Then
.OLEDBConnection.BackgroundQuery = False
End If
End If
End With
Connection.Refresh
Next Connection
Next bugfix
End Sub
推荐阅读
- typo3 - 使用新日期字段扩展 NEWS 后,如何从该新闻字段中列出
- android - Android Studio 是否损坏了我的项目文件?
- react-native - 我如何使用第 n 个孩子来反应原生?
- java - 字符串线程安全吗?
- docker - 一旦将docker上传到弹性beantalk,ffmpeg似乎消失了
- ffmpeg - 编码时更改FFmpeg中的参数?
- python - 具有 groupby 和聚合操作的简单并行处理 pandas Dataframe 块
- angular - Angular 7+ 中的共享动画
- c# - 如何在军刀汽车价格空气交换肥皂 api 请求中发送段号
- python - 在每次迭代时在带有标识列的 pandas 上迭代地创建一个数据框