+ Reply to Thread
Results 1 to 3 of 3

Change cell fill color for all cells in a workbook based on a cell value

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Change cell fill color for all cells in a workbook based on a cell value

    I want to have a work sheet named "Treatment" have a color key located from G3:G22. I want to be able to change the color for example on G3 to yellow. If the value in G3 is "sun" and I select yellow for the fill color, then that is the master/key for the entire workbook. I want to run VBA to look for any cell in the entire workbook and if it has a value of "sun", then it will automatically fill in yellow for the color.

    I have the below code that works well for ONE sheet called "Treatment" and the key is from G3:G22, but it only changes the values in column B. Is there any way to run a similar macro for the entire workbook, not just one sheet?

    Please Login or Register  to view this content.
    Thanks,

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

    Re: Change cell fill color for all cells in a workbook based on a cell value

    This will color each cell in all the sheets in the workbook based on the activecell. Hope you can use/modify this for your purpose.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-24-2012
    Location
    IL, USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Change cell fill color for all cells in a workbook based on a cell value

    Quote Originally Posted by JOHN H. DAVIS View Post
    This will color each cell in all the sheets in the workbook based on the activecell. Hope you can use/modify this for your purpose.

    Please Login or Register  to view this content.
    Thank you for the code John. I tried it out and I am getting a "runtime error '13' type mismatch" and I think it is because I am using general text in my key (G23:G22) and I have cells with the same text is generated from a vlookup and/or index(match) formula.

+ 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] Change a cells fill color. VBA to make another cell the same color and also changes.
    By PeteABC123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2016, 12:34 PM
  2. Replies: 6
    Last Post: 10-01-2015, 07:58 PM
  3. Macro to change cell text color based on darkness of cell fill color
    By cincyshirm61 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2014, 12:11 PM
  4. [SOLVED] change fill color of a range of cells based on color of a cell?
    By DarMelNel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 04:48 PM
  5. Replies: 3
    Last Post: 07-08-2010, 06:48 PM
  6. Change fill color based on another cell
    By George3232 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2010, 02:38 PM
  7. Change fill color based on value of another cell in Excel
    By ForensicAccountant in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2005, 02:10 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