【问题标题】:Refresh each excel sheet with 5-10 seconds用 5-10 秒刷新每个 Excel 表
【发布时间】:2020-04-26 14:13:05
【问题描述】:

我的 excel 中有 100 张工作表,我无法运行全部刷新,因为它给了我错误“[Microsoft] [ODBC Excel 驱动程序] 客户端任务太多。” 所以目前我必须转到每张纸并在延迟 5-10 秒后手动单击“刷新”按钮。 如何通过单击一个按钮在每次刷新之间延迟 5-10 秒自动“刷新”所有工作表?

提前致谢。

【问题讨论】:

    标签: excel vba refresh


    【解决方案1】:

    试试这样的:

    Sub RefreshData()
    
        Dim ws As Worksheet
        Dim qt As QueryTable
    
        For Each ws In ThisWorkbook.Worksheets
            For Each qt In ws.QueryTables
                qt.Refresh BackgroundQuery = False
            Next
        Next
    
        MsgBox "Refresh complete"
    
    End Sub
    

    替代方法:

    Sub RefreshData()
    
        Dim cn As WorkbookConnection
    
        For Each cn In ThisWorkbook.Connections
            cn.Refresh
        Next
    
    End Sub
    

    【讨论】:

    • 以上代码没有刷新任何工作表,最后只显示“刷新完成”消息。
    • 我添加了另一种方法,看看是否适合你
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 2013-05-02
    • 1970-01-01
    • 2015-06-11
    • 2015-07-20
    • 2013-04-06
    相关资源
    最近更新 更多