MsgBox打开时如何仍然在Excel中继续工作?

我在vba上运行代码,并使用MsgBox显示结果。 我想保留这些结果显示,因为我在一个单独的excel文件中input结果值,但Excel不允许我在另一个excel文件上工作,直到我按MsgBox上的确定或取消button。 如何保持msgbox上,仍然工作在单独的Excel文件?

不要使用MsgBox 。 使用自定义的Userform ,然后调用它显示为无模式

 UserForm1.Show vbModeless 

例如

 Sub Sample() ' '~~> Rest of your code ' MsgBox "Hello World" ' '~~> Rest of your code ' End Sub 

也可以写成

 Sub Sample() ' '~~> Rest of your code ' UserForm1.Label1.Caption = "Hello World" UserForm1.Show vbModeless ' '~~> Rest of your code ' End Sub