Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default autostart and "on" and "off" macro


Hopefully an easy one for all you gurus out there... :)

I have a macro, the contents of which aren't really necessary to post
here. I want that macro to "autostart" when the workbook is opened and
continue to repeat. I also need a seperate macro to break the loop and
stop the macro, and another to restart it (from the beginning).

Any help is much appreciated.


--
grime
------------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=546460

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default autostart and "on" and "off" macro

to start the macro use the workbook_Open event

http://www.cpearson.com/excel/events.htm

to repeat it use Application.Ontime
http://www.cpearson.com/excel/ontime.htm

that also includes how to stop it.

--
Regards,
Tom Ogilvy

"grime" wrote in
message ...

Hopefully an easy one for all you gurus out there... :)

I have a macro, the contents of which aren't really necessary to post
here. I want that macro to "autostart" when the workbook is opened and
continue to repeat. I also need a seperate macro to break the loop and
stop the macro, and another to restart it (from the beginning).

Any help is much appreciated.


--
grime
------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=546460



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default autostart and "on" and "off" macro


Thanks for the reply, Tom, but this isn't exactly my intention.

Here is my current macro (which works, i suppose, but there may be a
more elegant way)...


Code:
--------------------
Public Sub Macro1()
Do Until OnOff = 0
DoEvents
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default autostart and "on" and "off" macro

If you can get macro2 to run when macro1 is running, then I suppose that is
fine. I don't see the point of calling macro1 when you have set the variable
to off.

I think the references I gave your are better, but it depends on what you
are doing and how much time macro1 takes to run and if it needs to be run as
much as you have it run.

Also, what your are doing may better be handled with events - again, I don't
know what you are doing.

--
Regards,
Tom Ogilvy


"grime" wrote:


Thanks for the reply, Tom, but this isn't exactly my intention.

Here is my current macro (which works, i suppose, but there may be a
more elegant way)...


Code:
--------------------
Public Sub Macro1()
Do Until OnOff = 0
DoEvents
.
.
.
Loop
End Sub
--------------------



Code:
--------------------
Private Sub Macro2()
If OnOff = 0 Then
OnOff = 1
Macro1
ElseIf OnOff = 1 Then
OnOff = 0
Macro1
End If
End Sub
--------------------


Is there an easier way?


--
grime
------------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=546460


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... Maria J-son[_2_] Excel Programming 2 March 5th 06 12:20 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"