+ Reply to Thread
Results 1 to 6 of 6

2 cell condition sheet/tab color change, and VBA copying with sheet

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    3

    2 cell condition sheet/tab color change, and VBA copying with sheet

    Hi All,

    I need help to figure out how to use VBA to alter a tab's color based on the condition of two cells, as detailed below:

    If B1 and J1 are blank, leave tab color GREY.
    If B1 has a date, and J1 is blank, turn tab color RED.
    If J1 has a date, regardless of B1, turn tab color GREEN.

    The name of the sheet I am writing this for is named "Macro", and will ultimately be copied multiple times using the code below. I would like to know if/how I can ensure that the code I am currently trying to figure out will also be in place for the newly copied sheets, refering to their own B1 and J1 cells.

    Please Login or Register  to view this content.

    I am using Excel 2010.
    Thank you so much in advance for any assistance!

    Joe C.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,927

    Re: 2 cell condition sheet/tab color change, and VBA copying with sheet

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    01-06-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: 2 cell condition sheet/tab color change, and VBA copying with sheet

    Thanks protonLeah, but that didn't seem to work

    ...I tried using this both by adding it as the sheet code and adding it as a module to the workbook. The worksheet tab did not change color when I added a date in to cells B1 or J1.

    Did I do something wrong?

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,927

    Re: 2 cell condition sheet/tab color change, and VBA copying with sheet

    It worked as a standard code module with XL2007.

  5. #5
    Registered User
    Join Date
    01-06-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: 2 cell condition sheet/tab color change, and VBA copying with sheet

    So I tried this on a brand new XL2010 as a standard module, and it worked fine after saving as a macro enabled workbook. The file I am trying to use this for is a decently large (4-5mb) binary file. It didn't seem to work for that file, though my above posted macro works like a charm. Do you happen to know why one macro would work in binary workbook and another would not?
    EDIT: Well I figured this part out.. I didn't realize your code was specific to Sheet1 at first, and my spreadsheet didn't have a sheet named Sheet1

    A few questions:
    -Is there anyway to make this effect multiple specific sheets, but not all? (A single sheet will be copied approximately 500 times using my above macro, and I need this to effect all copies but nothing else) ..do you know if this macro will successfuly be duplicated through the use of my macro above (dynamic), or will it remain point at a single sheet even if it does copy as sheets are copied?

    -Is there anyway to make this happen automatically each time excel does a calculation, rather than having to run the macro?

    Thank you, again, protonLeah.
    Last edited by ohnoitsjoe89; 01-08-2014 at 12:44 AM.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,927

    Re: 2 cell condition sheet/tab color change, and VBA copying with sheet

    I tried the tab color macro in an xlsb and it worked (sheet change event).

    The only way I can see to have the one macro work on multiple sheets easily is to put in the the "ThisWorkbook" module as a sheet change event. In order to have it work on some sheets but not all, it would be be easiest if the sheets you want it to apply to have something in common in the name that could be tested with an IF..THEN statement. Alternatively, you could list the sheets you want to bypass and exit the code. For example:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 01-08-2014 at 01:04 AM.

+ 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. [SOLVED] How to change sheet tab color based on its condition
    By saesaria in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2013, 12:32 PM
  2. Copying data from one sheet to another based on cell color
    By Redcarn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2012, 03:16 AM
  3. Replies: 2
    Last Post: 05-11-2009, 01:41 PM
  4. How can I change sheet tab color based on cell value in sheet?
    By SCAScot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2005, 05:50 PM
  5. How do I change the Cell color automatically in an Excel sheet wh.
    By stump in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-06-2005, 11:06 AM

Tags for this Thread

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