首页 > 解决方案 > VBA 和 Bloomberg 应用程序。运行“RefreshAllWorkbooks”

问题描述

请就以下事项提出建议:

我有一个代码应该刷新我的工作簿中的公式,然后将结果作为值复制到另一张表。问题是代码会直接遍历所有内容并在刷新完成之前复制数据(刷新大约需要 10-15 秒)。

我使用了以下(及其品种),但它没有做任何事情来减慢它:

Application.Wait (Now + TimeValue("0:00:15"))

我是否必须执行一个循环来检查单元格内容并在识别单元格更新后执行“复制”部分?

Sub Excel_VBA_Timer_Event1()
Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim V As Workbook: Dim x, y, z As Worksheet
Set V = ThisWorkbook: Set x = V.Sheets(1): Set y = V.Sheets(2): Set z = V.Sheets(3)
z.Columns("A:O").EntireColumn.Delete

Aplication.Run "RefreshAllWorkbooks"

'WAIT HERE for approx 15 seonds
'At the moment the code flies through till the end before Bloomberg formulas are refreshed


y.Columns("C:M").Copy
z.Range("A1").PasteSpecial (xlPasteValues): z.Range("A1").PasteSpecial (xlPasteFormats)

z.Activate: z.Cells(1, 1).Select
Application.CutCopyMode = False

MsgBox "Done"

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

标签: vbabloomberg

解决方案


推荐阅读