Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2004, 04:21 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.


 
Old December 31st, 2004, 05:46 AM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Not sure what the RTD function is, not a standard one though.

I did notice that you Dim 'tempFormula' with an 'r' on the end. If you don't have Option Explicit, this could be causing the problem.

Otherwise, let us know about the RTD function.

Cheers,
Andrew






Similar Threads
Thread Thread Starter Forum Replies Last Post
Range Validator dcct84 C# 2 October 12th, 2007 08:30 AM
"Unable to set the FormulaArray property..." rduncan1 Excel VBA 2 August 18th, 2006 01:33 PM
FormulaArray problem Golem Excel VBA 0 December 28th, 2005 03:59 AM
Getting chart range help munkiller Excel VBA 1 June 24th, 2005 05:37 AM
Range selection keithd Excel VBA 7 April 7th, 2005 11:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.