Help with Delay function

  • Thread starter Thread starter bradikus
  • Start date Start date
B

bradikus

I would like to create a delay function such that it's cell or anothe
are changed sometime after the referenced cell is changed, withou
holding up other cell caculations during the delay.

I have tried the following code but still no go.


Code
-------------------

Function DELAY(NewValue As Integer, pauseTime As Integer)
Dim callingRow As Integer
Dim callingCol As Integer
Dim callingSheet As Integer
Dim callVars As String

callingRow = Application.Caller.Row
callingCol = Application.Caller.Column
callingSheet = Application.Caller.Parent.Index
callVars = "change_States " & NewValue & ", " & callingRow & ", " & callingCol & ", " & callingSheet
Application.OnTime Now + TimeSerial(0, 0, pauseTime), callVars

End Function

Sub change_States(NewValue As Integer, callingRow As Integer, callingCol As Integer, callingSheet As Integer)
MsgBox "Look I made it here!!"
Worksheets(callingSheet).Cells(callingRow, callingCol + 1) = NewValue
End Sub
 
I don't think you will get away with this. A function can return a value,
but I don't think it can fire another macro to update that cell,
asynchronously or not. You will see if you take the OnTime out and call it
directly, it bombs.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

bradikus > said:
I would like to create a delay function such that it's cell or another
are changed sometime after the referenced cell is changed, without
holding up other cell caculations during the delay.

I have tried the following code but still no go.


Code:
--------------------

Function DELAY(NewValue As Integer, pauseTime As Integer)
Dim callingRow As Integer
Dim callingCol As Integer
Dim callingSheet As Integer
Dim callVars As String

callingRow = Application.Caller.Row
callingCol = Application.Caller.Column
callingSheet = Application.Caller.Parent.Index
callVars = "change_States " & NewValue & ", " & callingRow & ", " &
callingCol & ", " & callingSheet
Application.OnTime Now + TimeSerial(0, 0, pauseTime), callVars

End Function

Sub change_States(NewValue As Integer, callingRow As Integer, callingCol
As Integer, callingSheet As Integer)
 

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

Back
Top