Can I run a Sub based on whether another Sub Has run? (EXCEL VBA) -
all, have userform , trying allow users use 2 different text boxes search worksheet based on value in either text box. form populates other boxes based on active cell. question is: can write code 2 subs check if other 1 has executed? pseudocode below:
>sub statustextbox_afterupdate() >>'check if transittextbox_afterupdate() has run >>>'if yes end sub >>>>'if no carry on rest of statustextbox_afterupdate()
this change value of transittextbox pull worksheet, , want prevent transittextbox_afterupdate() running. problem transittextbox populated afterupdate event runs , 2 conflict. there way of preventing this?
use global variable allow 2 subs communicate:
public imdone boolean sub shouldrunfirst() imdone = true end sub sub shouldrunsecond() if imdone msgbox "first macro has been run" else msgbox "first macro has not run yet" end if end sub
edit#1:
we need make communication variable visible across board:
- dim in standard module
- put declaration @ top of module
- declare public
it should "visible" subs, , events. see of answers here
Comments
Post a Comment