+ Reply to Thread
Results 1 to 17 of 17

Coloring Cells based on adjacent cell color

  1. #1
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Coloring Cells based on adjacent cell color

    Howdy,
    I need a macro that will check for the color green in each cell in Column K and make the adjacent cell in Column L the same color if it returns as green. In Column M and N, it needs to match what ever the color is in Column L. Easy to do?

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Coloring Cells based on adjacent cell color

    Hi

    It would have been good if you could upload a sample file. And one more thing: will there be some data in col K?
    Last edited by jraj1106; 01-04-2013 at 12:45 AM.
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    The cells may or may not have data in them. It just needs to check colors if that is possible. Here is an example workbook.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    I forgot to color some of the cells, here is the corrected book.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Coloring Cells based on adjacent cell color

    Check this macro:


    Please Login or Register  to view this content.
    Good Day.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Coloring Cells based on adjacent cell color

    If col K is not green then do you want cols M and N to be yellow?

  7. #7
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    If K is not green, then the cells can be yellow or orange. I have a macro to color L yellow or orange based on the cell value. There may not be content in M or N. So if M and N uses L as its color choice then that will work for my project.

  8. #8
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    The macro isn't working for me.

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

    Re: Coloring Cells based on adjacent cell color

    Hi smugglersblues,

    Try this:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    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

  10. #10
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    That macro isnt working either. I'm using Office 2010, could that be an issue?

  11. #11
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Coloring Cells based on adjacent cell color

    Sorry about that. Paste this code into your file:

    Please Login or Register  to view this content.

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

    Re: Coloring Cells based on adjacent cell color

    That macro isnt working either. I'm using Office 2010, could that be an issue?
    No.

    Were you on Sheet1 when you ran the macro? Are the macros in the workbook enabled? Also, if the cells were already coloured green then you wouldn't see any change.

  13. #13
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    Here's the workbook with both macros. Does it work for either of you? When I run either one they don't appear to do anything.
    Attached Files Attached Files

  14. #14
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Coloring Cells based on adjacent cell color

    The macro didn't work because you had put my code in a module. I'll explain what you need to do:

    In the file that I had uploaded there's a button. Its on sheet1. So in the code window click on the sheet1 code page and paste the code that I had uploaded previously. It will work.

    Bye...

  15. #15
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    Quote Originally Posted by Trebor76 View Post
    No.

    Were you on Sheet1 when you ran the macro? Are the macros in the workbook enabled? Also, if the cells were already coloured green then you wouldn't see any change.
    Hi Trebor,
    I've tried it on sheet1, this work book and in a module. I know that private sub and public subs don't mix too well but I was checking it just to see what would happen. No matter where I put the code, it isn't working on my computer.

  16. #16
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Coloring Cells based on adjacent cell color

    Hi Trebor,
    Your code works GREAT! The problem I was having is that I am red/green colorblind. I was picking the wrong green out of the color palette. So the code works now that I have the right color (color picker in Photoshop works wonders). Thanks for your help.

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

    Re: Coloring Cells based on adjacent cell color

    Thanks for the feedback and I'm glad to hear we were able to sort it out for you.

+ 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