+ Reply to Thread
Results 1 to 2 of 2

Evaluate function in VBA

  1. #1
    Registered User
    Join Date
    03-07-2010
    Location
    Leamington, uk
    MS-Off Ver
    Excel 2003
    Posts
    1

    Evaluate function in VBA

    I have written a user-defined function to evaluate text that looks like a formula. In the simple example attached:

    Cell named length has value 2
    Cell named breadth has value 3
    Cell named height has value 5

    Cell D5 has text 'Length * Breadth' then Cell named Area calculates using my User Defined Function as Eval(D5)

    Similarly I get the value for Volume as Area * Height

    The formula is:

    Please Login or Register  to view this content.
    In Excel 2003 all worked fine. In Excel 2007 there seems to be a problem with the automatic calculation process. Opening the spreadsheet the Volume does not calculate, instead it shows #NAME. Editing a cell forces the calculation to be done. Then if I edit the length the area is calculated, but not the volume. Excel is re-calculating once, but not the two times that is needed.

    Any thoughts on how to get the calculation correct?

    Thanks
    Keith
    Attached Files Attached Files
    Last edited by keith101; 03-07-2010 at 06:46 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Evaluate function in VBA

    Welcome to the forum.

    You could make your function less ambiguous and more versatile:

    Please Login or Register  to view this content.
    Then you can also do,

    =eval("length*height")

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1