如何在调用不同的Excel宏时显示状态消息?

如何在调用不同的Excel宏时显示状态消息?,excel,vba,Excel,Vba,我有一个更新透视表的按钮,并调用3个不同的excel宏来执行大数据更新。我想在每个宏之间显示一条更新消息,让用户知道哪个数据块正在更新 Sub Button11_Click() 'Update Volumes Set pt = Sheets("PRE Vol. Data").PivotTables("PRE Volumes") With pt .RefreshTable End With 'Update Uniformance Call PullUniformanceDa

我有一个更新透视表的按钮,并调用3个不同的excel宏来执行大数据更新。我想在每个宏之间显示一条更新消息,让用户知道哪个数据块正在更新

Sub Button11_Click()
'Update Volumes
    Set pt = Sheets("PRE Vol. Data").PivotTables("PRE Volumes")
With pt
    .RefreshTable
End With
'Update Uniformance
    Call PullUniformanceData
'Update All Pad Data
    Call FillDowntoDate_Click
'Update OE Line Data
    Call FillDowntoDateLineData_Click
End Sub

用户表单可以用来提供更新吗?我希望更新内容为“更新步骤1/4”。

互联网上有很多示例tbh。要回答您的问题,可以在运行其他代码时启动
vbModeless
userform,这些代码可以通过触发器进行更新。互联网上有很多示例tbh。要回答您的问题,是,
vbModeless
userform可以在其他代码运行时启动,可以通过触发器进行更新。
Sub Button11_Click()
   'Update Volumes
    Set pt = Sheets("PRE Vol. Data").PivotTables("PRE Volumes")
    With pt
      .RefreshTable
    End With
    UpdateMessage("Refresh table complete")

    'Update Uniformance
     Call PullUniformanceData
     UpdateMessage("Uniformance Data Complete")

    'Update All Pad Data
     Call FillDowntoDate_Click
     UpdateMessage("DowntoDate complete")
    'Update OE Line Data
     Call FillDowntoDateLineData_Click
     UpdateMessage("DowntoDateLine Data Complete")

     UpdateMessage("All Macros completed")
End Sub

Sub UpdateMessage(strMessage As String)
    ''assuming you have form "frmMain"setup with a text box
    frmMain.txtStatus.Caption = strMessage

    '' If you dont have a form, then use a cell that you prefer
    set ws = Sheets("Sheet1") 'update here the sheet you want to show
    set loc = ws.cells(1,1)' update here to point to the cell you want the message to show

    loc.Value = strMessage
    DoEvents ' dont forget this call

End Sub