У меня есть саб, как показано ниже:
Function SumOf(Byval a As Integer, Byval b As Integer)
Call CalHelper.Sum(a,b)
Call CalHelper.Sum(a+1,b+1)
SumOf = "OK"
End Function
А Модуль CalHelper содержит:
'BEGIN Declare
Private mWindowsTimerID As Long
Private mApplicationTimerTime As Date
Private numberA As Variant
Private numberB As String
'END Decalare
'Register `user32` lib's functions BEGIN
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long _
) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, _
ByVal nIDEvent As Long _
) As Long
'Register `user32` lib's functions BEGIN
Sub Sum(ByVal a As Integer, ByVal b As Integer)
On Error Resume Next
mCacheUrl = keyy
mCacheValue = valuee
On Error GoTo 0
If mWindowsTimerIDCache <> 0 Then
KillTimer 0&, mWindowsTimerICache
End If
mWindowsTimerID = SetTimer(0&, 0&, 1000, AddressOf AfterUDFRoutine1)
End Sub
Private Sub AfterUDFRoutine1()
' Stop the Windows timer
On Error Resume Next
KillTimer 0&, mWindowsTimerID
On Error GoTo 0
mWindowsTimerID= 0
' Cancel any previous OnTime timers
If mApplicationTimerTimeCache <> 0 Then
On Error Resume Next
Application.OnTime mApplicationTimerTime, "AfterUDFRoutine2", , False
On Error GoTo 0
End If
mApplicationTimerTime = Now
Application.OnTime mApplicationTimerTime, "AfterUDFRoutine2"
End Sub
Private Sub AfterUDFRoutine2()
' Do tasks not allowed in a UDF...
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
sum =numberA + numberB
roww = Sheets(AddSheetCacheHelper.SHEET_CACHE_NAME).Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheet("Result").Cells(roww,1).Value = sum
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Моя проблема в функции SumOf, выполняется только одна сумма вызова. Я думаю, потому что 2 вызова sub происходят одновременно, поэтому mApplicationTimerTime
- это то же самое, и Applicaition.OnTime
unknown должен быть запущен, что?
Обновление SumOf
- это функция в моей надстройке. Это не макрос.