+ Reply to Thread
Results 1 to 7 of 7

Coding to make tab colour change based on conditional formatting colour of cell range

  1. #1
    Registered User
    Join Date
    01-22-2016
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    12

    Coding to make tab colour change based on conditional formatting colour of cell range

    Good Morning All,

    I've got a workbook that has a couple of worksheets.

    I have conditional formatting set up on all cells in the range F8 to AC47 which turns red if the date entered is over 6 months old.

    As the first tab 'Section 1' will load up first and people won't always go into the second worksheet 'Section 2' I wanted to apply code to ws 'Section 2' so that the tab colour changes to red if any of the cells within the range F8 to AC47 are red due to the conditional formatting applied on them.

    Basically so that it alerts the user that the second worksheet needs action as something is over 6 months old and so now 'out of date' so to speak.

    And then the code would then make the tab colour go 'no colour' again once the red cell has been resolved and there are no red cells in the range F8 to AC47 again.

    Any help would be much appreciated as I've been trying all sorts of coding but can't quite get it right.

    Thanks
    DC

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Coding to make tab colour change based on conditional formatting colour of cell range

    Hi there,

    Insert the following code into the ThisWorkbook VBA CodeModule and see if it does what you need:

    Please Login or Register  to view this content.
    The highlighted value can be altered to suit your own requirements.

    Opening the workbook will set the tab colour of each worksheet appropriately.

    When date values are changed on a worksheet, the tab colour of that worksheet will be set when the worksheet is deactivated, i.e. when a different worksheet is selected.



    By including the following code it is possible to have the tab colour update each time the value of a date cell is changed, but it adds an (in my opinion) unnecessary overhead unless this facility is essential.

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    01-22-2016
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    12

    Re: Coding to make tab colour change based on conditional formatting colour of cell range

    Hi Greg M,

    Thanks for your reply.

    I've added formula in and it works well however, it only goes green if there is no data inputted in any of the cells (F8:AC47) as I see you've ran it on being over 6 months old and I have some old dates in the range F8:AC47. My conditional formatting is set up so that, as an example in F8 there is the date of the first revision of the document say 10/10/2015 then in cell G8 the conditional formatting makes the cell red if it the date in F8 is over 6 months ago. So in this instance cell G8 would be red to highlight a new revision is needed so if that were done today then 11/04/2016 would be entered in the red cell making the red disappear in G8 due to conditional formatting and then H8 will be no colour as it is today's date in G8 so less than 6 months old. However, when we get to 12/10/2016 cell H8 will go red due to the date in G8 being over 6 months by then and so the new revision date will need to be entered in H8, and this process carries on across to column AC.

    What I really need is rather than the tab colour going red if there is dates older than a certain date I need the tab colour to go red if any of the cells in F8:AC47 have gone red due to the date in the cell to the left of it entered being older than 6 months.

    What I mean is that I can't have the tab go red based on whether there is a date entered that is over 6 months old as I need all the previous document revision dates left in the previous cells.

    Is there a way of making the tab colour go red if any cells within F8:AC47 have gone red do you know?

    Hope that makes sense.

    Thanks again for your help.
    DC
    Last edited by DC93; 04-11-2016 at 08:57 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Coding to make tab colour change based on conditional formatting colour of cell range

    Try this

    Put all these in the module for sheet "Section 1"
    The tab is black unless at least one of the cells has display format color 255
    It checks whenever any value in Section 1 changes



    Please Login or Register  to view this content.
    If a response has helped then please consider rating it by clicking on *Add Reputation below the post
    When your issue has been resolved don't forget to mark the thread SOLVED (click Thread Tools at top of thread)

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Coding to make tab colour change based on conditional formatting colour of cell range

    Hi again,

    Thanks for your prompt feedback.

    Could you post a sample worksheet here? Even a sample which includes only the date cells range would be helpful, as it would enable me to see more clearly what you have in mind.

    Regards,

    Greg M

  6. #6
    Registered User
    Join Date
    01-22-2016
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    12

    Re: Coding to make tab colour change based on conditional formatting colour of cell range

    Kevin# - That works perfectly for what I needed, thanks a lot. Been driving me crazy all day that has.

    Greg M, thanks a lot for your help as well, your coding worked perfectly if I based it on checking for dates in cells as opposed to colours so that is really helpful to know and something I will definitely need to use in the future so I will make a note of that.

    Have a good day both.

    DC

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Coding to make tab colour change based on conditional formatting colour of cell range

    Hi again,

    Thanks for that - glad you found my post useful.

    Best regards,

    Greg M

+ 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: 02-22-2015, 11:52 AM
  2. How to make a range colour equal a cell colour
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 10:17 AM
  3. [SOLVED] Change cell colour based on text being present - conditional formatting?
    By rob-the-randy-rascal in forum Excel General
    Replies: 8
    Last Post: 08-01-2013, 11:24 AM
  4. [SOLVED] Conditional Formatting to Change Cell Colour Based on Date
    By Kym2101 in forum Excel General
    Replies: 5
    Last Post: 05-01-2012, 11:41 PM
  5. How to make row change colour based on text colour in row?
    By Joanna13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-02-2010, 04:39 PM
  6. Replies: 5
    Last Post: 10-03-2009, 04:31 PM
  7. conditional formatting to change colour of cell based on formula result
    By gideong in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-15-2009, 09:35 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