+ Reply to Thread
Results 1 to 5 of 5

Custom function not working automatically

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    61

    Custom function not working automatically

    Hi All,

    I am desperately in need of your excel help. I have the below custom function:

    Public Function GetFillColor(range) As Long
    Application.Volatile
    GetFillColor = range.Interior.ColorIndex
    End Function

    I am working on an intelligent rostering spreadsheet which identifies a certain sector based on the color coding of a time range. I am suing the above function to return the color index of the cell range which in order helps derive a logical function to achieve my purpose. However, in a selected range, a large number of cells are blank cells, therefore, this function doesnt work automatically - it requires the user to hit enter or change another cell in the spreadsheet. these logical functions in turn populate a summary sheet elsewhere, therefore, the functions need to be live. In order to circumvent this problem, i tried to incorporate a live clock into the sheet which updated per second - the logic was this ensures the sheet stays live by the second. however, it has introduced other problems - the clock stops everytime a macro is run and also the screen and the cursor is pulsing every second which is very annoying. however, if this custom function can be run withoiut any intervention - it solves all my problems. Could someone please show me the way to achieve this? Many thanks in advance!!

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Custom function not working automatically

    Changing the interior color does not trigger an event. You might be able to live with a sheet selection event to force a sheet calculation. Right click sheet's tab, View Code, and paste.
    Please Login or Register  to view this content.
    I would suggest changing the input to a different variable name and set type as Range. e.g.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Custom function not working automatically

    Quote Originally Posted by Naz555 View Post
    Public Function GetFillColor(range) As Long
    "range" is a reserved word in vba - Range, as Kenneth Hobson wrote

    ColorIndex of blank cell is -4142 (old excel)

  4. #4
    Registered User
    Join Date
    07-10-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Custom function not working automatically

    Thanks heaps guys! That was very very helpful! It works! legends!!

  5. #5
    Registered User
    Join Date
    07-10-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Custom function not working automatically

    hi Kenneth, i have just realised that using ActiveSheet.Calculate has resulted in the inability to copy paste within the sheet. Is there a workaround for this please?

+ 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. Custom function for stock quotes not working
    By kioolt in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-25-2017, 09:58 PM
  2. Replies: 0
    Last Post: 11-20-2015, 12:34 PM
  3. DAY() function is not working for custom date format
    By milindbharambe in forum Excel General
    Replies: 17
    Last Post: 04-24-2014, 07:19 AM
  4. Can't get Custom Function to Load Automatically
    By chippy502 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 03:11 PM
  5. Custom Function not working...
    By h20worker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2011, 01:31 PM
  6. Custom Function for Complex numbers not working.
    By shahmegh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-20-2010, 10:47 AM
  7. Custom Function not working
    By jhahes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2006, 12:29 AM

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