Help! RTD and Range.FormulaArray
Hi! All!
I have been spending four days to solve some excel problem.
At first, try to review following code.
==========================
Public preData As String
Public dataRange As Range
Public pFormula As String
Function calldata() As Variant
On Error GoTo errHandler
Dim tempArray As Variant
Static cnt As Integer
Dim rowSize As Integer, colSize As Integer
Dim tempFormular As String
preData = Excel.Application.WorksheetFunction.RTD("ExcelRTD. RTDFunctions", "", "healthcheck")
tempArray = Evaluate(preData)
rowSize = UBound(tempArray, 1)
colSize = UBound(tempArray, 2)
Dim sRange As Range
Set sRange = Range("A1")
Set dataRange = Range(sRange, sRange.Offset(rowSize - 1, colSize - 1))
Call viewData(cnt Mod 5)
If tempFormula = 0 Then
dataRange.FormulaArray = pFormula ----(1)
Debug.Print pFormula & ":" & dataRange.FormulaArray
End If
cnt = cnt + 1
Debug.Print "cnt:" & cnt & ",a2 value=" & Range("A2").Value
calldata = Now & ""
Exit Function
errHandler:
Debug.Print Err.Number, Err.Description
End Function
Sub viewData(no As Integer)
Select Case no
Case 0
pFormula = "=0"
Case 1
pFormula = "=1"
Case 2
pFormula = "=2"
Case 3
pFormula = "=3"
Case 4
pFormula = "=4"
End Select
Debug.Print "pFormula=" & pFormula
End Sub
===========================
when I excute the colde line by line with debug F8 Key, the value is setted correctly, but If I execute that without line by line execution then the value got original value always and I can't execute that program correctly.
Anybody has a good idea to solve this problem?
Thank you.
|