![]() |
Click event to run only once
HI again, I apologise for my persistence but im really stuck!! Can someone sho me how to apply so that my click event runs only once?? Thanks in advance! -- gavme ----------------------------------------------------------------------- gavmer's Profile: http://www.excelforum.com/member.php...nfo&userid=666 View this thread: http://www.excelforum.com/showthread.php?threadid=26497 |
Click event to run only once
One way to do it is to use a Static variable, so it
retains its value between calls. If you use a Boolean, you can use it to flag when the sub has been run previously, and if so to abort processing the code; e.g: Sub Button1_Click() Static Pressed As Boolean If Not(Pressed) Then ' Insert your code here End If Pressed = True End Sub First time this is run, Pressed starts out false so your code runs. But then Pressed is set to True and the value is retained between calls - so next time it will fail the IF statement and the code will be bypassed. K Dales -----Original Message----- HI again, I apologise for my persistence but im really stuck!! Can someone show me how to apply so that my click event runs only once?? Thanks in advance!! -- gavmer ---------------------------------------------------------- -------------- gavmer's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=6662 View this thread: http://www.excelforum.com/showthread...hreadid=264970 . |
All times are GMT +1. The time now is 01:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com