excel - How can I wait for a specific code to run while when form is closed and is set to vbModeless? -
i have macro generates report show our bank , accounting records tie out day. in end of macro userform
displays if discrepancy detected , allows user remove listbox
once have taken care of discrepancy.
in order user analyze input data (which imported workbook on separate sheet) while keeping userform
open (to track discrepancies), set userform.show vbmodeless
. issue i'm trying implement new function run after userform
closed in modeless
state, checks if condition met , moves on.
i tried implement goto x
in okbutton
event listener, i'm not sure how have code goto
line in main module
when referenced within userform
.
my question: how can keep userform
set modeless
, , allow user navigate through data open, not continue code unless it's closed / unloaded / okbutton pressed?
here's button listener:
private sub okbutton_click() '.... code here me.hide leftovervalues.closed = true '(other userform if discrepancies not taken care of) closed = true 'boolean flag closed goto unmatchedsummaryclosed: '(name of form, goto line in module) end sub
here's code end of macro - calling userform
end:
'... approx 2000 lines worth of code leading application.screenupdating = true beep 'to alert users it's 'finished' if wirevalues.count > 0 or bwgpvalues.count > 0 call differenceform 'discrepancy userform - named unmatchedsummary end if beep 'alert show discrepancy check done - shows if needed call warnform unmatchedclosed: 'intended goto line userform if unmatchedsummary.closed , leftovervalues.closed , warningform.closed call arsummary end if call stoptimer(time1, started1) 'timer show how long macro took debug.print "total time: " & showtime(time1) & "ms" if unmatchedsummary.closed , warningform.closed , arsummarydone end 'also want happen if everything's done end if ' don't want data hang if user doesn't close macro template end sub
you can try putting call function want run in userform_terminate()
fires when userform closed.
Comments
Post a Comment