Sabtu, 01 Juni 2013

[ExcelVBA] Prevent macro from being run twice

 


I've made a sort of psychological test in excel.

I don't want it to be run more than once.

I have made a range called runbefore, and if the value is greater than zero the macro ends with a msgbox.

At the start of the sub

sub test()

if range("runbefore").value > 0 then
msgbox("run before")
end
endif
 .........

range("runbefore").value =1

end sub

can this be done with a static variable - does it keep its value after the sub is run and finished?

or

in another way?

regards Torstein

Can this be done with a static variable - does the staic variable keep its value after the macro has run?

or in another way?

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar