+ Reply to Thread
Results 1 to 6 of 6

Set cell background color by color index

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    Sinagpore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Set cell background color by color index

    Hi,

    Now i m using color index to count the colored cell. The function that i m using is:
    Please Login or Register  to view this content.
    Then, in a cell put this formula using particular range:

    =CountByColor(A1:A10,3)

    This will count all the cells in A1:A10 that have the color red.

    This function is post by shades, however the color index "3" is for red. Any of you know how what are the color index for blue, green and yellow?

    Thanks
    Last edited by JosephP; 03-27-2013 at 03:23 AM. Reason: add code tags

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Set cell background color by color index

    Ms Bean.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window.


    BTW, if you select a colored cell and run this macro, you'll get the Color Index Number.

    Please Login or Register  to view this content.
    Last edited by jolivanes; 03-26-2013 at 01:42 AM. Reason: Add code

  3. #3
    Registered User
    Join Date
    03-25-2013
    Location
    Sinagpore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Set cell background color by color index

    Jolivanes,

    sorry for the inconvenience caused, next time i will do that according to the rules. Thanks for your info^^

    However, when i save the file and reopen again, it show error to my formula. For example "=CountByColor(A1:A10,3)" it becomes #NAME? So what should i do to make it become normal with the formula that i set earlier?

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Set cell background color by color index


  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Set cell background color by color index

    Ms Bean

    Have a look at the attached.
    Slighly different UDF (borrowed from Mr Jim May)

  6. #6
    Registered User
    Join Date
    03-25-2013
    Location
    Sinagpore
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Set cell background color by color index

    Thanks for your help

+ 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