Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Pausing or waiting in VBA

I come to a point in my VBA code where an array formula is calculated and it
pulls data from a DDE link, so the calculation is not always instantaneous
as it takes a few seconds to retrieve the data. In the meantime the program
continues to step forward and I am getting an error message at a point where
I am trying to assign a value to a variable based on a cell that is
dependent on the aforementioned calculation of the array formula.

I first tried just using a message box to freeze the program long enough for
the array formula to compute, but it froze it froze the array formula too,
so no help there. So, I sort of feel like a dog chasing its tail here. I am
not certain I know what I need but some sort of code after this:

Selection.FormulaArray = MySecondFormula

where the program pauses until the array formula has pulled its data in from
the DDE source and calculated the cell values, then as the code continues to
step forward, there would be a value where and when I need it to pass along
to the variable. I only get an error now.

My thanks in advance for any suggestions.

Cheers! Brad


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Pausing or waiting in VBA

Don't wait. Just leave the macro and rely on an Application.OnData event to
trip when the transfer is complete.



--Gary's Student


"Brad" wrote:

I come to a point in my VBA code where an array formula is calculated and it
pulls data from a DDE link, so the calculation is not always instantaneous
as it takes a few seconds to retrieve the data. In the meantime the program
continues to step forward and I am getting an error message at a point where
I am trying to assign a value to a variable based on a cell that is
dependent on the aforementioned calculation of the array formula.

I first tried just using a message box to freeze the program long enough for
the array formula to compute, but it froze it froze the array formula too,
so no help there. So, I sort of feel like a dog chasing its tail here. I am
not certain I know what I need but some sort of code after this:

Selection.FormulaArray = MySecondFormula

where the program pauses until the array formula has pulled its data in from
the DDE source and calculated the cell values, then as the code continues to
step forward, there would be a value where and when I need it to pass along
to the variable. I only get an error now.

My thanks in advance for any suggestions.

Cheers! Brad



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Pausing or waiting in VBA

Brad,
The following allows ten seconds to retrieve the
MySecondFormula value or it displays a message and
continues on. It assumes the first cell in the selection is blank.
You could alter this to provide alternatives...

Dim TimeNow As Date
TimeNow = Timer
Selection.FormulaArray = MySecondFormula
Do
If TimeNow + 10 < Timer Then
MsgBox "Didn't Work "
Exit Do
End If
Loop Until Len(Selection(1).Value) 1
------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Brad"
wrote in message
I come to a point in my VBA code where an array formula is calculated and it
pulls data from a DDE link, so the calculation is not always instantaneous
as it takes a few seconds to retrieve the data. In the meantime the program
continues to step forward and I am getting an error message at a point where
I am trying to assign a value to a variable based on a cell that is
dependent on the aforementioned calculation of the array formula.

I first tried just using a message box to freeze the program long enough for
the array formula to compute, but it froze it froze the array formula too,
so no help there. So, I sort of feel like a dog chasing its tail here. I am
not certain I know what I need but some sort of code after this:

Selection.FormulaArray = MySecondFormula

where the program pauses until the array formula has pulled its data in from
the DDE source and calculated the cell values, then as the code continues to
step forward, there would be a value where and when I need it to pass along
to the variable. I only get an error now.
My thanks in advance for any suggestions.
Cheers! Brad
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 pausing BAR Excel Discussion (Misc queries) 0 January 27th 10 09:57 PM
Is there a way of pausing a macro Shazza Excel Discussion (Misc queries) 2 March 12th 07 10:59 PM
Pausing a macro while waiting for an input into a cell Francois Ashton[_2_] Excel Programming 3 July 19th 06 01:06 PM
pausing a macro Hasan Cansü[_2_] Excel Programming 6 February 27th 04 06:40 PM
Pausing a VBA macro Dean Taylor Excel Programming 1 August 1st 03 05:44 PM


All times are GMT +1. The time now is 03:23 PM.

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

About Us

"It's about Microsoft Excel"