+ Reply to Thread
Results 1 to 6 of 6

Assign unique colors for each cell in a range

  1. #1
    Registered User
    Join Date
    06-24-2015
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Assign unique colors for each cell in a range

    I have a range in excel A1:C2 I have a cell with a value which would repeat in other locations of the range and would like to assign unique color to these cells in the range. Similarly for other values in the range.

    The worksheet would look something like the attached once it is solved.

    I found a script which isn't exactly working for my range. Thanks a lot for your attention and any help will be appreciated.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by FDibbins; 06-24-2015 at 01:04 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Assign unique colors for each cell in a range

    Hi, welcome to the forum

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

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] 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. More information about these and other tags can be found here

    I will add them for you - this time.

    Your question is confusing, and your file doesnt help much either (well, to me, anyway)

    Are you trying to color all cells that do not duplicate (per your heading), or all cells that match some other cell (per your post)?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-24-2015
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Re: Assign unique colors for each cell in a range

    Thanks for your reply FDibbins and apology for not following rule 3. I shall take care of it in my future posts.

    Going back to my question, as you can see in the workbook, Range A1:C2 has three (viz, ABC, CCC & RRR) types of values in it. My requirement is to have one color for cells with values ABC, another color for CCC and a different color for RRR throughout the range. It should assign unique color to a cell in a range. Hope this helps.

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Assign unique colors for each cell in a range

    Hi krishnakashyap,

    Welcome to the forum and thanks for wrapping your with the appropriate tags as Ford as requested.

    This code will colour code each unique item, though the colour it gives for each unique item will be different each time you run it:

    Please Login or Register  to view this content.
    Regards,

    Robert
    Last edited by Trebor76; 06-24-2015 at 06:25 AM.
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  5. #5
    Registered User
    Join Date
    06-24-2015
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Re: Assign unique colors for each cell in a range

    Thanks a lot for the reply Trebor76.

    Before I could mark this thread as solved, I had one last requirement. The above code works great, and I had to extend this code for an additional requirement wherein code has to assign unique colors based on the first three letters of the cells.
    Attached is the example. I greatly appreciate your help and time.

    Thanks again.
    Regards,
    Krishna
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Assign unique colors for each cell in a range

    Hi Kirshna,

    I had to extend this code for an additional requirement wherein code has to assign unique colors based on the first three letters of the cells.
    There's not a lot to change:

    Please Login or Register  to view this content.
    I did add a range variable called "rngMyRange" so you can set the range once.

    Regards,

    Robert

+ 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. Assign different colors to diagram
    By Thomas_Graf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-11-2015, 01:18 PM
  2. Assign unique ID IF adjacent cell has unique value
    By attaboy000 in forum Excel General
    Replies: 1
    Last Post: 06-05-2014, 02:17 PM
  3. Replies: 1
    Last Post: 11-19-2012, 12:04 PM
  4. Replies: 0
    Last Post: 07-24-2012, 05:49 PM
  5. Unable to assign 6 colors
    By ice_breaker in forum Excel General
    Replies: 2
    Last Post: 10-16-2007, 01:04 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