+ Reply to Thread
Results 1 to 9 of 9

VBA Calculate Pause

  1. #1
    Registered User
    Join Date
    02-23-2007
    Posts
    19

    VBA Calculate Pause

    Hi everyone I am having a little trouble with a sheet i'm currently working on. Having exhausted what i believe to be every avenue trying to do this without VBA, i've finally had to sucomb to it as i can't see an alternative and i'm no VB expert by any means! This is what i have so far:

    Please Login or Register  to view this content.
    Basically what i am trying to do is insert a pause, sleep, wait etc. command into my IF statement.

    If cell J10 (10, 10) = 1 or 2, pause for 300 milliseconds, then fill cell M10 (10, 13) with the value 3.

    I am aware the wait and sleep commands cause excel not to funtion while the command is in use. Ideally i would like everything to perform as usual just that specific cell is paused. I use a program that writes all the data into Excel and it updates every 250ms hence my above effort is under Worksheet_Calculate().
    Last edited by VBA Noob; 03-16-2009 at 02:58 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Calculate Pause

    Hello jc0r,

    I have added a 250 millisecond delay to your code. This will still process events in the background but delay the macro's execution. It isn't a high accuracy timer but tests on my machine were accurate to within 500 microseconds. The Timer counts the seconds from midnight since Windows was last started. It updates every microsecond.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-23-2007
    Posts
    19

    Re: VBA Calculate Pause

    Thankyou very much for taking the time on this, very much appreciated. I shall test this later and when i get the oppotunity and post back.

    Thanks once again!

  4. #4
    Registered User
    Join Date
    02-23-2007
    Posts
    19

    Re: VBA Calculate Pause

    Just posting back to say the script you posted works a treat, thankyou!

    One other thing, in the script you posted would it be possible to only display the result if true, i.e.
    Please Login or Register  to view this content.
    for a limited amount of time such as 2 seconds?

    thanks again!

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Calculate Pause

    Hello jc0r,

    Do mean display the value in a message box or some other way?

  6. #6
    Registered User
    Join Date
    02-23-2007
    Posts
    19

    Re: VBA Calculate Pause

    The result of the formula if true = 3. I have other formulas that run off the result of this formula however when it is true i only want them to run for a limited time. So in answer to your question, when the script returns a value of true, 3 will appear in cell (10, 13). Is there a way to have the result 3 only appear in the cell (10, 13) for 2 seconds, then after that remove the number 3 and the cell be blank?

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Calculate Pause

    Hello jc0r,

    Adding another timer loop and setting it for 2 seconds and clearing the cell should work. Try this...
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-23-2007
    Posts
    19

    Re: VBA Calculate Pause

    Once again, thankyou so much, done the trick nicely! Now if only i had your knowledge on such things i wouldnt be such a pain in the ***! :D

  9. #9
    Registered User
    Join Date
    11-01-2012
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: VBA Calculate Pause

    Thanks this helped alot! quick and simple solution to an annoying problem!

    --
    IJ

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1