+ Reply to Thread
Results 1 to 18 of 18

CNTCOLOR formula does not update automatically when I change the cell color

  1. #1
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    CNTCOLOR formula does not update automatically when I change the cell color

    Hope someone can help me on this. I have one excel sheet with the color cells counting for the vacation days. But when I change the color of the cells the count does not update automatically and I have to go to each cell to press enter or double click to make the counts updated. How can I resolve this issue?

    Here is one example of my formula: =cntcolor(D4:AH4,$O$1)

    Thanks in advance for your help.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,640

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Hi
    is this a UDF?

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    That is a perfect example of why you should not base calculations on cell formats.

    Try to write a formula using built-in functions based on WHY the cells are formatted the way they are.

    Do the cells have conditional formatting applied? If so, what is the CF rule that applies the formatting?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    This is not a UDF.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Quote Originally Posted by tracyxiao View Post
    This is not a UDF.
    cntcolor is not a native Excel function.

    It may be part of an add-in.

  6. #6
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    I think you are right. I do not own this file but got it from someone else and try to work on the file but find this problem. How can I find whether it is a UDF or part of an add-in?

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    If it is in a VBA module as a FUNCTION, then it is a UDF.
    ALT F11 to open VBA Editor and then look in the modules for something like

    FUNCTION cntcolor(x as range....)
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Quote Originally Posted by ChemistB View Post
    If it is in a VBA module as a FUNCTION, then it is a UDF.
    ALT F11 to open VBA Editor and then look in the modules for something like

    FUNCTION cntcolor(x as range....)

    Function CntColor(rng As Range, Fclr As Range) As Long
    For Each c In rng
    If c.Interior.ColorIndex = Fclr.Interior.ColorIndex Then
    CntColor = CntColor + 1
    End If
    Next
    End Function

  9. #9
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    That is the code for CNTColor.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Changing a cell format does not trigger a calculation.

    You can make the function volatile (it will recalculate when some event triggers a calculation) but you will still have the problem you're having.

    This is why I advise against basing calculations on cell formats.

  11. #11
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    So there is no way to actually make it automated if we keep this UDF, right?

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Not that I'm aware of.

    However, someone that knows more about VBA than I do might have a solution.

  13. #13
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Quote Originally Posted by Tony Valko View Post
    Not that I'm aware of.

    However, someone that knows more about VBA than I do might have a solution.

    Thanks. That is very helpful.

  14. #14
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    If the cells are formatted using conditional formatting then it should be relatively easy to come up with a formula to get the count based on the CF rule(s).

  15. #15
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    The cells are not formatted but we manually change the color for each cell for the holiday or vacation days.

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    Quote Originally Posted by tracyxiao View Post
    The cells are not formatted but we manually change the color for each cell for the holiday or vacation days.
    Ok, how about using a helper column to identify whether the date(?) is a holiday or a vacation day?

    Enter a H for holiday or V for vacation.

    Then you just need to count the Hs or Vs.

  17. #17
    Registered User
    Join Date
    12-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    That is a good idea. But need to add 20 columns. And the date of the calendar is with formula. I think that might be hard to do that. Another thing is the calendar includes several years. I just feel that is not the best way. Still thanks for your advice.

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: CNTCOLOR formula does not update automatically when I change the cell color

    No good options for this.

    Using a bunch of helper cells is not especially desirable.

    You could still use your CNTCOLOR function and every time you apply the cell format press function key F9 to force a calculation then the formula will update.

    Again, this is not ideal but those are your options.

+ 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. Replies: 2
    Last Post: 11-10-2011, 07:43 AM
  2. Replies: 3
    Last Post: 07-08-2010, 06:48 PM
  3. Having Cell Color Change Automatically Based on Value
    By jamesfedwards in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-21-2006, 10:47 AM
  4. Replies: 7
    Last Post: 04-04-2006, 11:20 PM
  5. [SOLVED] Change text color in a cell automatically
    By Dajana in forum Excel General
    Replies: 0
    Last Post: 11-07-2005, 08:35 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