Home Stop a do loop with a command button
Reply: 0

Stop a do loop with a command button

user528
1#
user528 Published in April 24, 2018, 8:25 am

I have a VBA excel userform that is misbehaving. Basically I want my code to pause until a command button on a userform is pressed. Any ideas?

In a module:

Public okayclicked as boolean

Sub MyThing
  UserForm1.Show
  Do Until okayclicked
     DoEvents
  Loop
 UserForm1.Hide
End Sub

In my userform:

Sub CommandButton1_Click()
   okayclicked = True
End Sub

Not sure what else to try to make this work. Any help is appreciated! Thanks!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.331541 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO