Results 1 to 7 of 7

How to change the colour of so many cells in a row based on a value?

Threaded View

  1. #1
    Registered User
    Join Date
    03-12-2010
    Location
    Basingstoke, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    How to change the colour of so many cells in a row based on a value?

    I have this code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Set MyPlage = Range("J3:J13")
    For Each Cell In MyPlage

    If Cell.Value = "On Duty" Then
    Cell.Interior.ColorIndex = 4
    End If
    If Cell.Value = "Off Duty" Then
    Cell.Interior.ColorIndex = 3
    End If
    If Cell.Value = "Incident" Then
    Cell.Interior.ColorIndex = 3
    End If

    If Cell.Value = "Off Route" Then
    Cell.Interior.ColorIndex = 46
    End If

    If Cell.Value = "Broken Down" Then
    Cell.Interior.ColorIndex = 46
    End If

    If Cell.Value = "Welfare Break" Then
    Cell.Interior.ColorIndex = 46
    End If

    If Cell.Value = "Change Over" Then
    Cell.Interior.ColorIndex = 46
    End If

    If Cell.Value <> "On Duty" And Cell.Value <> "Off Duty" And Cell.Value <> "Incident" And Cell.Value <> "Off Route" And Cell.Value <> "Broken Down" And Cell.Value <> "Welfare Break" And Cell.Value <> "Change Over" Then
    Cell.Interior.ColorIndex = xlNone
    End If
    Next
    End Sub
    It does exactly as I want it to do, however I want cells B3 - J3 and so on down to B13 - J13 to turn a certain colour instead of just the individual cell changing. I have modified the code to "Target.EntireRow", but it's not the entire row I need. Any help would be greatly appreciated.
    Last edited by Scoodman; 10-21-2010 at 11:16 AM.

Thread Information

Users Browsing this Thread

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

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