+ Reply to Thread
Results 1 to 3 of 3

Change the formula of a target cell in a self-defined worksheet function

  1. #1
    Registered User
    Join Date
    02-07-2007
    Posts
    5

    Change the formula of a target cell in a self-defined worksheet function

    HI Guys

    I got a problem when I wrote a self-defined worksheet function. The idea is very simple: change the formula of a target cell. A simplified function is like this:
    Please Login or Register  to view this content.
    if I call the function under the following sub, every is fine
    Please Login or Register  to view this content.
    However, if I call the function in a cell
    like: PrintFormula("=PROPHETX|QUOTE!'QNGM8[DTN:NYMEX]?Last'")
    I got error, the Range("C1").formula is always empty and the error is Application-defined or object-defined error.

    Do you guys have any idea about this problem? Thanks
    Last edited by Leith Ross; 04-29-2008 at 12:28 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello mxcaocao,

    There are restrictions on what a User Defined Function or UDF can do.

    Let's focus on what it can not do:
    1) Change the Format or of any other cell, including its own.
    2) Change the Formula of any cell, including it own.
    3) Call other VBA macro to do these things.

    Basically, it can only return a value to the cell the function is in.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-07-2007
    Posts
    5
    Thanks for you answer. It looks like that what I want to do is kind of "mission impossible"

+ 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