Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Two Macros at the same time?? is it possible
Hi, And Many Thanks in advance! I would like to add a timing range and /or Shape, button to show for a while "10 Seconds" the time going down and while going down be able to press one other button, and run the macro attached to it. Is it Posibble?? My Try: For X = 10 To 0 Step -1 Activesheet.Buttons("Time").Caption = X 'or Range("A1").Value=X Application.Wait Now + TimeValue("00:00:01") Next X 'so when I am showing this timing going down, be able to press a few other macros. Am I missing anything, is it possible?? Do I have to attach any doevents?? do loop?? Any Idea? Thanks -- 0000_AAAA_0000 ------------------------------------------------------------------------ 0000_AAAA_0000's Profile: http://www.excelforum.com/member.php...o&userid=12480 View this thread: http://www.excelforum.com/showthread...hreadid=277113 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Two Macros at the same time?? is it possible
Look in help at DoEvents
-----Original Message----- Hi, And Many Thanks in advance! I would like to add a timing range and /or Shape, button to show for a while "10 Seconds" the time going down and while going down be able to press one other button, and run the macro attached to it. Is it Posibble?? My Try: For X = 10 To 0 Step -1 Activesheet.Buttons("Time").Caption = X 'or Range("A1").Value=X Application.Wait Now + TimeValue("00:00:01") Next X 'so when I am showing this timing going down, be able to press a few other macros. Am I missing anything, is it possible?? Do I have to attach any doevents?? do loop?? Any Idea? Thanks -- 0000_AAAA_0000 ---------------------------------------------------------- -------------- 0000_AAAA_0000's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=12480 View this thread: http://www.excelforum.com/showthread...hreadid=277113 . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Two Macros at the same time?? is it possible
no. sorry to say. when one macro is running, it has
command of the CPU. no other actions or interrupt requests can proceed untill the macro has stopped. You can throw in a few doevents but that will only free the CPU to do system events. so running 2 macros at once is not possible. as for a timer for the macro, unforumately there is no timer control built in to excel. you can use the status bar by adding application.statusbar = "yourmessage" in your code at various stages to let you know about where the macro is but that is about it. when done make sure you set the status bar to nothing. sorry. Regards Frank -----Original Message----- Hi, And Many Thanks in advance! I would like to add a timing range and /or Shape, button to show for a while "10 Seconds" the time going down and while going down be able to press one other button, and run the macro attached to it. Is it Posibble?? My Try: For X = 10 To 0 Step -1 Activesheet.Buttons("Time").Caption = X 'or Range("A1").Value=X Application.Wait Now + TimeValue("00:00:01") Next X 'so when I am showing this timing going down, be able to press a few other macros. Am I missing anything, is it possible?? Do I have to attach any doevents?? do loop?? Any Idea? Thanks -- 0000_AAAA_0000 ---------------------------------------------------------- -------------- 0000_AAAA_0000's Profile: http://www.excelforum.com/member.php? action=getinfo&userid=12480 View this thread: http://www.excelforum.com/showthread...hreadid=277113 . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Two Macros at the same time?? is it possible
Hi,
Yes, you can do this (kind of). As Frank pointed out, you cannot run 2 separate VBA procedures at once. However, you could use Application.OnTime to "run" your countdown timer. Between calls to the subroutine used in OnTime (which would change the caption of your countdown button), your users would be able to click other buttons to launch other macros. But the OnTime procedure would not run again until the other code had finished with its execution. -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] 0000_AAAA_0000 wrote: Hi, And Many Thanks in advance! I would like to add a timing range and /or Shape, button to show for a while "10 Seconds" the time going down and while going down be able to press one other button, and run the macro attached to it. Is it Posibble?? My Try: For X = 10 To 0 Step -1 Activesheet.Buttons("Time").Caption = X 'or Range("A1").Value=X Application.Wait Now + TimeValue("00:00:01") Next X 'so when I am showing this timing going down, be able to press a few other macros. Am I missing anything, is it possible?? Do I have to attach any doevents?? do loop?? Any Idea? Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Two Macros at the same time?? is it possible
OnTime might well fail if the other code is running at the the time that the
OnTime call is meant to be processed. It's clunky and has rarely worked reliably for me, so I came up with an activex wrapper for the VB timer. You can download this VBA timer from my site below. As an illustration, I have just tested the following in Excel XP. Create a form, with one command button, two labels, and add the VBA control to the form. Set the timer properties to enabled and an interval of 1000, then run the form. When first launched you'll see label1 updating with the time. When you click the command button, you'll see the time continue to be updated even while label2 shows the counter value. Private Sub CommandButton1_Click() Dim lCounter As Long For lCounter = 1 To 10000000 Label2.Caption = lCounter DoEvents Next lCounter End Sub Private Sub Timer1_Timer() Label1.Caption = "The time is: " & Time End Sub Robin Hammond www.enhanceddatasystems.com "Jake Marx" wrote in message ... Hi, Yes, you can do this (kind of). As Frank pointed out, you cannot run 2 separate VBA procedures at once. However, you could use Application.OnTime to "run" your countdown timer. Between calls to the subroutine used in OnTime (which would change the caption of your countdown button), your users would be able to click other buttons to launch other macros. But the OnTime procedure would not run again until the other code had finished with its execution. -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] 0000_AAAA_0000 wrote: Hi, And Many Thanks in advance! I would like to add a timing range and /or Shape, button to show for a while "10 Seconds" the time going down and while going down be able to press one other button, and run the macro attached to it. Is it Posibble?? My Try: For X = 10 To 0 Step -1 Activesheet.Buttons("Time").Caption = X 'or Range("A1").Value=X Application.Wait Now + TimeValue("00:00:01") Next X 'so when I am showing this timing going down, be able to press a few other macros. Am I missing anything, is it possible?? Do I have to attach any doevents?? do loop?? Any Idea? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
running macros at specified time | Excel Discussion (Misc queries) | |||
First time deleting macros | Excel Discussion (Misc queries) | |||
Time keys in macros | Excel Discussion (Misc queries) | |||
Time Delay for Macros | Excel Discussion (Misc queries) | |||
running macros at a set time | Excel Discussion (Misc queries) |