Halting code

  • Thread starter Thread starter rob nobel
  • Start date Start date
R

rob nobel

I would like to know if it is possible to include some code that will Halt
any other code from functioning until a button is clicked to allow that code
to run again? (I have a procedure that opens a modeless uf, so that data can
be entered on the sheet with that uf still present. I need to stop the user
selecting any other buttons that are on the sheet whilst this modeless uf is
open.)

Rob
 
You could make a public boolean variable that you set when you show you
modeless form.

Have all other code check the value of that variable and not run if it so
indicated

if bBlockCode = True then Exit sub

at the top

=True added for clarity, obviously it is redundant.
 
Hi Tom.
Thanks for your suggestion. I'll give it a go. At first look it seems easy
enough but I'm sure I'll be back with a question.
Rob
 
Sorry Tom, I'm back. I am having trouble with this as the userForm is
called from another procedure which is not a sheet module (just an ordinary
module) and I can't seem to get the other procedures in another Ord module
to recognise the variable.
Although I understand reasonably well where to put code and such, I'm still
having trouble with where to put variables and how to define them.
What I did was put .... Public bBlockCode As Integer at the top of the
module for the uf,
and put.... bBlockCode =sheet4.range("N13") within the code of the uf,
and then.... if bBlockCode =1 Then Exit Sub in the code of the other
modules so that if it is 1 any of those modules will exit.
It seems that bBlockCode will change it's value from 0 to 1 OK but that is
not recognised by the other modules as when the procedure moves to the
modules the variable shows as "empty".
Hope you can help me with this.
Rob
 
Back
Top