我试图每天早上 9 点运行一个宏。我正在尝试使用 OnTime 应用程序并测试了宏以在特定时间启动,但它不能自动工作。我必须手动运行宏才能弹出消息框。有什么建议吗?
Sub FinancialAlert()
Application.OnTime TimeValue("15:33:00"), "Summary of Covered Companies"
Dim i As Long
i = 5
While Workbooks("Montreal Issuers.xlsm").Sheets("Summary of Covered Companies").Cells(i, 5) <> ""
With Workbooks("Montreal Issuers.xlsm")
If .Sheets("Summary of Covered Companies").Cells(i, 5).Value = 1 Then
MsgBox Workbooks("Montreal Issuers.xlsm").Sheets("Summary of Covered Companies").Cells(i, 3).Value & " is issuing their next financial statement tomorrow (" & _
Format(Workbooks("Montreal Issuers.xlsm").Sheets("Summary of Covered Companies").Cells(i, 4).Value, "[$-409]mmmm d, yyyy;@") & ")."
End If
If .Sheets("Summary of Covered Companies").Cells(i, 5).Value = 0 Then
MsgBox Workbooks("Montreal Issuers.xlsm").Sheets("Summary of Covered Companies").Cells(i, 3).Value & " is issuing their next financial statement today (" & _
Format(Workbooks("Montreal Issuers.xlsm").Sheets("Summary of Covered Companies").Cells(i, 4).Value, "[$-409]mmmm d, yyyy;@") & ")."
End If
End With
i = i + 1
Wend
End Sub