Results 1 to 5 of 5

Modify Code to change cell background color

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-16-2008
    Location
    Mansfield, TX
    Posts
    324

    Modify Code to change cell background color

    Hello, I have the code below set to change the background color based on certain conditions. What I need to do is change it so that if none of the conditions are met, it does not change the color at all. As it is written now, if anything is entered in a cell that has a background already set, but does not meet these conditions, the cell turns white.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim icolor As Integer
    
     On Error GoTo ErrorHandler
     
     
    'change the conditions below
      Select Case Target.Value
               Case "OFF"
                    icolor = 35
                Case "RTO"
                    icolor = 8
                Case "vacation"
                    icolor = 8
                Case "10-9 SBP"
                    icolor = 38
                Case Else
            End Select
    
     
      Target.Interior.ColorIndex = icolor
    ErrorHandler:
        On Error Resume Next
        
     
    
    End Sub

    Thanks!
    Clayton Grove
    Last edited by VBA Noob; 11-12-2008 at 02:49 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