VBA learn how you can click a button to start running the program, and then click Close?

 

 

3 ideas to suspend the program

  • 暂停  application.wait(now + timevalue("00:00:03"))  和 application.ontime(now + timevalue("00:00:03"))
  • sleep 500
  • To break, and then F5 to run what not to suspend it?
  • stop it not, is suspended the program runs
  • When the program is running hang of it, you can only add to suspend the code to allow you to play
  • do event

 

 

Do Until b = True
  DoEvents
Loop

 

Private Sub CommandButton1_Click()
b = False
UserForm1.Show 0
Do Until b = True
  DoEvents
Loop
MsgBox [a1] & [a2] & [a3] & Chr(10) & "Done!"
End Sub

Private Sub CommandButton2_Click()
[b1:b100] = "123abc"
End Sub

 

Detailed requirements

  • Do not have that, tap the button Run, tap on pause function Well
  • Your needs have to say fine point
  • Tap, it is a SUB finish, or intermediate pause?
  • Another point is to re-run a sub or then run?
发布了383 篇原创文章 · 获赞 45 · 访问量 10万+

Guess you like

Origin blog.csdn.net/xuemanqianshan/article/details/104052457