+ Reply to Thread
Results 1 to 4 of 4

Change the colour of a Row when a condition changes in a cell

  1. #1
    Registered User
    Join Date
    11-02-2011
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2003
    Posts
    1

    Change the colour of a Row when a condition changes in a cell

    Hello

    I have a workbook with several sheets in Excel 2003 and was using conditional formatting to change the colour of a Row when a certain condition was met. As an example if I selected "C" from a drop down list it would change the colour of the row to orange. it worked fine but now I have more than 3 conditions so I needed some code to allow for 4 or 5 conditions.

    I found this code and adapted it for my spreadsheet but it just won't work! I have also disabled all the conditional formatting that I had in each sheet. I tried putting the code in the "workbook" and no luck so I have the code in every sheet but it still won't work. ANY help would be really appreciated.

    Private Sub Worksheet_Change(ByVal Target As Range)

    Set VacancyListOfferWoods = Range("A2:AY300")

    For Each Cell In VacancyListOfferWoods

    Select Case Cell.Value

    Case Is = "C"
    Cell.EntireRow.Interior.ColorIndex = 7

    Case Is = "F"
    Cell.EntireRow.Interior.ColorIndex = 8

    Case Is = "DB"
    Cell.EntireRow.Interior.ColorIndex = 4

    Case Is = "Q"
    Cell.EntireRow.Interior.ColorIndex = 3

    Case Else
    Cell.EntireRow.Interior.ColorIndex = xlNone

    End Select

    Next
    End Sub

  2. #2
    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: Change the colour of a Row when a condition changes in a cell

    Hi,

    Use the following Workbook_SheetChange event - note Workbook sheet change not Worksheet change

    Please Login or Register  to view this content.
    Regards
    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.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Change the colour of a Row when a condition changes in a cell

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Change the colour of a Row when a condition changes in a cell

    Does this belong in the Access forum? Moved to Excel Programming.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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