Freeze the value of one cell for secs while worksheet auto updates

G

Gum

I have the freeze the value of an output from a macro for a specified parts
of a second while the rest of the worksheet continues to be updated.
I have used the formulation:

Sheets("Sheet1").Range("A1") = 1
Application.Wait Now + TimeValue("00:00:01")

but this freezes the entire application for the specifed duration.

I have also used a loop:

for count =1 to 10000
Sheets("Sheet1").Range("A1") = 1
Next count

but looping effectively freezes the application

The value ..."A1" is required to be sent via DDE to another application, and
this process is held up until the 2 procedures (mentioned above) are
completed, which defeats the purpose.

What is the solution?
 
G

Gary''s Student

Perhaps:

Sub wait_a_bit()
For i = 1 To 1000
DoEvents
Next
MsgBox ("Have I waited enough?")
End Sub
 
G

Gum

The method was tried as referred to in my question:

for count =1 to 10000
Sheets("Sheet1").Range("A1") = 1
Next count

where DoEvents was: Sheets("Sheet1").Range("A1")=1 above.
While the result was the cell had the value 'frozen', the effect of
effectively shutting down the application for the duration of the loop (e.g,
DDE values were not updated) meant that the objectives were not realized.
 
G

Gary''s Student

DoEvents should not freeze the application. It should allow it to run in
bursts.

Try increasing the counter
 
G

Gum

I doubled the counter and the application froze for the same duration as the
cell freeze, albeit a longer period freezing. There were no bursts during
the freeze period.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top