+ Reply to Thread
Results 1 to 7 of 7

UDF works in 2003, but fails in 2007

  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    Iver, England
    MS-Off Ver
    Excel 2007 & 2003
    Posts
    4

    UDF works in 2003, but fails in 2007

    I have a user defined function which works in Excell 2003, but fails in Excel 2007.

    Please Login or Register  to view this content.
    I have some code which copies a range from another workbook and then pastes this into the open workbook.
    The user can choose whether to paste the data as "Values" or as "Link".
    There is a cell in the worksheet which uses the "IsFormula" function to check the first cell of the pasted range to see if it contains Data (i.e. it is pasted values) or a Formula (i.e. it is linked) and then display a message to let the user know that they are currently using linked data or pasted values.
    The whole thing worked perfectly in Excel 2003, but in Excel 2007 when the range is pasted, the "IsFormula" function gives a "#VALUE!" error. At this point F9 (recalc) sometimes cures the problem, but not always.
    Copying the data in the referenced cell to another cell, then copying back again also cures the problem.

    Any explanation of what is going on and how to solve it would be much appreciated.
    TIA
    Peter Ross
    Last edited by Puff_Adder; 04-05-2010 at 06:23 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UDF works in 2003, but fails in 2007

    Works fine in 2007
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    04-02-2010
    Location
    Iver, England
    MS-Off Ver
    Excel 2007 & 2003
    Posts
    4

    Re: UDF works in 2003, but fails in 2007

    Thanks, but not really very helpful. How did you test it?

    I realise that the UDF works in 2007 when used to reference a cell into which data or a formula has been entered manually or pasted manually.
    However, the problem I have is that it fails when the pasting is executed by VBA code.

    Any suggestions?

    Peter Ross

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: UDF works in 2003, but fails in 2007

    I created a workbook in 2007, added the Function & used it to test A1.

    When I copied & pasted a formula into A! it returned True, using PasteSpecial it returned False

  5. #5
    Registered User
    Join Date
    04-02-2010
    Location
    Iver, England
    MS-Off Ver
    Excel 2007 & 2003
    Posts
    4

    Re: UDF works in 2003, but fails in 2007

    Thanks Roy,
    I get the same result (i.e. it works) when pasting manually.
    The problem only seems to occur when the pasting is executed by VBA code.
    The code must be OK as it works perfectly in Excel 2003.

    Any suggestions?

  6. #6
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848

    Re: UDF works in 2003, but fails in 2007

    If I change your Function to:
    Please Login or Register  to view this content.
    and add:
    Please Login or Register  to view this content.
    to a sub doing a paste operation, the formula calculates.

    Without using Application.Volatile and Application.Calculate combination, I was left with the #Value as the formula's result.

  7. #7
    Registered User
    Join Date
    04-02-2010
    Location
    Iver, England
    MS-Off Ver
    Excel 2007 & 2003
    Posts
    4

    Re: UDF works in 2003, but fails in 2007

    Thanks for your help, but for some reason your solution doesn't work for me.
    No need to bother any further though as I found a way to achieve what I wanted without using the IsFormula function.
    I just use the VBA code to enter the required message, depending on which pasting method was chosen, rather than using the UDF to check for presence of values or linked formula.
    Can't believe I didn't think of that in the first place.

+ 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