+ Reply to Thread
Results 1 to 8 of 8

Can I change the colour of my entire worksheet based on the value of one cell?

  1. #1
    Registered User
    Join Date
    04-02-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Can I change the colour of my entire worksheet based on the value of one cell?

    I have a spreadsheet that is being used as a user form. In one of the drop menus the user has the option to set the form as 'Draft' or 'Original'.

    I would like to be able to tell my entire worksheet to change colour if the cell is set to 'Draft', making it obvious to the user that the form is not an original.

    I have trawled through Q&A's trying to find an answer and can only find reference to Conditional Formatting, but in Excel 2010 I cannot find a way to extend the formatting to the entire sheet, just to rows or columns.

    Any help would be appreciated.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    Assuming drop down is cell A1

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-02-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    Thank you very much for the help, but it doesnt seem to be working (I am a VBA novice though, so its not surprising).

    Please advise if Im expecting the wrong thing here, but I expect that when I make the selection from the drop box that the sheet changes colour at that point (ie no buttons, keyboard shortcuts etc).

    My Draft and Original has been changed as I now have 4 selections (Pre Completion, Pre Completion Revised, Post Completion and Post Completion Revised) all in a drop box (C20), I need the sheet to change colour if either of the "Pre Completion" selections are made. I have tweaked your script slightly (to match my sheet) as below and pasted it to the foot of my existing VBA for this workbook:

    Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = Range("C20").Address Then
    Select Case UCase(Target.Value)
    Case Is = "POST COMPLETION"
    Cells.Interior.ColorIndex = xlNone
    Case Is = "POST COMPLETION REVISED"
    Cells.Interior.ColorIndex = xlNone
    Case Is = "PRE COMPLETION"
    Cells.Interior.ColorIndex = 6
    Case Is = "PRE COMPLETION REVISED"
    Cells.Interior.ColorIndex = 6
    End Select
    End If

    End Sub

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

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    Another:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-02-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    John, thank you very much for your help.

    Can I just check how I am supposed to introduce your script to my VBA?

    I currently have a number of scripts set up in the "this workbook" section as this is a document I am sharing with users outside of my business (so want the scripts to follow the document as it is emailed etc) and thought I would need to just paste your script below it (this is all I have done for the 3 scripts I currently have in the sheet and they all just work dynamically as I change selections in the sheet), but when I paste your script to the foot of the sheet and change C20 to either of the "pre" options, nothing happens.

    I presume its just me introducing your code to Excel/VBA incorrectly, but if you could point me in the right direction it would be greatly appreciated and I am sure it will work.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    Hi,

    Assuming A1 contains the word draft then use the CF

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    set the format and in the Apply To box enter

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    where Z is a column that is completely empty and 1:1 is a row that's completely empty.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    Instead of clicking on ThisWorkbook, in the VBE click on the Sheet you want the events to occur (ie right above ThisWorkbook). A drop-down window will appear on the right hand side. On the left select worksheet. On the right select Change. The code should be pasted there.

  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Can I change the colour of my entire worksheet based on the value of one cell?

    Your code should work if you put it in the correct spot. See John's post above

    Please Login or Register  to view this content.

+ 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. Copying Entire row based off cell value or conditional cell colour
    By jpl4412 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2013, 10:03 AM
  2. Change colour of cells based on another cell's colour (Not value)
    By LTrain89 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-25-2013, 08:44 PM
  3. Colour change column chart based on cell colour
    By Alice21 in forum Excel General
    Replies: 11
    Last Post: 04-05-2011, 10:10 AM
  4. Replies: 1
    Last Post: 10-01-2010, 09:51 AM
  5. Change cell colour based on sum
    By BekPen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2009, 05:50 PM

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