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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -