Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 11th, 2005, 11:11 PM
Registered User
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel macro application pause.

Can anyone tell me how can i pause or stop the application in the middle of my program for a few seconds and continue running back after that.

Sleep xxxx dont work because it still running the application.

i had tried many inbuild functions, but still can't find out ...

Pls help. thanks.

 
Old November 12th, 2005, 01:20 AM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You want it to pause while you're debugging or just stop it where it's at while it's running?

If you're debugging you can 'run to cursor'

If you want to stop it in the middle at least on mine you can just hit escape then it will give you the options "help", "debug", "continue"

Is that what you wanted?

 
Old November 12th, 2005, 02:36 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Use this code for waiting 5 seconds

Sub Wait()
' Waits 5 seconds
Application.Wait Time + TimeSerial(0, 0, 5)
' Continues here after pause
End Sub

-vemaju

 
Old November 12th, 2005, 01:58 PM
Registered User
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to stop in the middle of running.

Vemaju,
   Your subroutine almost help.
Let me explain more detail on it.

my sheet 1 is connected to FLUKE DAQ so the cell value is changing in real time. It will always trigger on that sheet.
What i want is running macro at the background, keep on polling the triggering cell and detect for change.
I am not familiar with macro, and i found out that once i run the macro, the sheet will stop triggering.

I am not sure macro can do kinda multithread thing, where the macro running at background and the cell value still triggering.

Hope you guys can help....
Thanks a lot.







 
Old November 12th, 2005, 02:46 PM
Registered User
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think i can't do it. Do you guys have any other idea?

"The only thing you cannot do is work in the foreground on the same workbook which the macro is using."

http://exceltips.vitalnews.com/Pages...s_Running.html


 
Old November 21st, 2009, 04:36 AM
Registered User
 
Join Date: Feb 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks

Quote:
Originally Posted by vemaju View Post
Hi,

Use this code for waiting 5 seconds

Sub Wait()
' Waits 5 seconds
Application.Wait Time + TimeSerial(0, 0, 5)
' Continues here after pause
End Sub

-vemaju

Vemaju!! Thank you. I was looking for a similar solution too and this one is a simple yet perfect one.

Thanks again
 
Old November 25th, 2012, 01:10 PM
Registered User
 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA Excel Sleep

tested on Excel 2010 and 2013, still works great! http://checktechno.blogspot.com/2012/11/vba-sleep.html

TimeValue also handle string time format. Using TimeValue("00:00:05") vs TimeValue(0,0,5)

Code:
Public Sub Test2()
    Application.Wait(Now + TimeValue("0:00:03"))
    MsgBox("hello")
End Sub
@hunchgun : I am not sure macro can do kinda multithread thing, where the macro running at background and the cell value still triggering.

is more complicate....





Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro in Excel mateenmohd Excel VBA 3 June 16th, 2008 07:34 PM
How to add Macro in other OutLook Application VBA kvingupta All Other Wrox Books 0 April 3rd, 2006 05:38 AM
Macro excel mathb79 Excel VBA 3 August 13th, 2005 06:55 PM
Excel 2000 vs Excel 2002 Macro Issue williadn Excel VBA 1 July 14th, 2005 09:09 AM
Excel 4.0 macro sezak99 Excel VBA 1 September 21st, 2003 11:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.