+ Reply to Thread
Results 1 to 3 of 3

user function works in vba, but not when called from worksheet

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    user function works in vba, but not when called from worksheet

    Hi all,

    I have the very simple function below - it works fine when called from VBA (?ccf(range("A1:B10")), but not from worksheet "=ccf(A1:B10)" and I don't get why...

    Please Login or Register  to view this content.
    anyone any great idea?

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: user function works in vba, but not when called from worksheet

    No one...?

    The function detects if a cell is formatted as "bad" via conditional formatting (so the pink interior color, with red font) and counts the number of occurrences.
    I really don't understand why it works from the immediate window, but not from a worksheet.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: user function works in vba, but not when called from worksheet

    Read this and you'll know why it doesn't work in worksheet UDF but does in Immediate window.

    It's DisplayFormat that's causing the isuue here.

    https://docs.microsoft.com/en-us/off....displayformat
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] DLL function crash excel when called from worksheet
    By gibus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-09-2017, 02:34 AM
  2. [SOLVED] Determine what called a user defined function?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-03-2016, 03:23 PM
  3. [SOLVED] Sub works when debugging but not when called from another sub.
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-06-2015, 05:37 AM
  4. User Defined function getting called for all the formula calculation cells
    By 1man in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2014, 08:36 AM
  5. Can a Function( ) called from within worksheet write to another cell?
    By 1Gunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2012, 04:19 PM
  6. [SOLVED] How to reference the name of the module in which a function is called in a worksheet
    By candy.chiu.ad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2012, 01:28 PM
  7. UDF working when called from Sub, doesn't work as worksheet function
    By stevenf in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-28-2009, 07:32 PM

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