![]() |
User initiated break/actions during macro execution
Hi, I'm trying to build an Excel (2000) application for teaching kid about the normal curve in statistics. Essentially, the program draw repeated random samples from a column of data and then plots the mean of each sample (the more samples you draw, the closer the chart wil look like a normal curve). Right now I've got the main code set up in a "for...next" loop tha loops through 1,000 times. But I'd like to set the macro up to run i an infinite loop until the user presses a stop button. Is such a thin possible? Mentally, I'm imagining the code as "do until the use presses button." But I can't figure out if it's possible for a use event to halt an action rather than initiate it. Can anyone help m out? A sub-problem to this is that I'd like to allow the user to adjust th speed of the macro as it runs (the idea being, the first couple time through the user might want the program to pause briefly between loop to discuss it with his/her students but then speed it up to build th graph quickly). I figured I'd just put a spinner control on th spreadsheet and tie it to some sort of "wait" or "ontime" code in m main macro. But the same problem exists as in the paragraph above: ho to allow users initiated actions DURING macro execution. Anyone know how I can get the functionality I'm looking for or am dreaming? Thanks, Martin Barro -- mbarro ----------------------------------------------------------------------- mbarron's Profile: http://www.excelforum.com/member.php...fo&userid=1484 View this thread: http://www.excelforum.com/showthread.php?threadid=26472 |
User initiated break/actions during macro execution
Litter you code with the
DoEvents command. another approach would be to restart the code with application.Ontime, but this would beg the question of where you are storing your results. http://www.cpearson.com/excel/ontime.htm Chip Pearson's site. -- Regards, Tom Ogilvy "mbarron" wrote in message ... Hi, I'm trying to build an Excel (2000) application for teaching kids about the normal curve in statistics. Essentially, the program draws repeated random samples from a column of data and then plots the means of each sample (the more samples you draw, the closer the chart will look like a normal curve). Right now I've got the main code set up in a "for...next" loop that loops through 1,000 times. But I'd like to set the macro up to run in an infinite loop until the user presses a stop button. Is such a thing possible? Mentally, I'm imagining the code as "do until the user presses button." But I can't figure out if it's possible for a user event to halt an action rather than initiate it. Can anyone help me out? A sub-problem to this is that I'd like to allow the user to adjust the speed of the macro as it runs (the idea being, the first couple times through the user might want the program to pause briefly between loops to discuss it with his/her students but then speed it up to build the graph quickly). I figured I'd just put a spinner control on the spreadsheet and tie it to some sort of "wait" or "ontime" code in my main macro. But the same problem exists as in the paragraph above: how to allow users initiated actions DURING macro execution. Anyone know how I can get the functionality I'm looking for or am I dreaming? Thanks, Martin Barron -- mbarron ------------------------------------------------------------------------ mbarron's Profile: http://www.excelforum.com/member.php...o&userid=14844 View this thread: http://www.excelforum.com/showthread...hreadid=264727 |
All times are GMT +1. The time now is 06:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com