Bill4tektips
Technical User
I am currently working with Excel 2003 and I have a spreadsheet that I have added some code to to change the cell and font colours. If I change the colours to something different from original, I then have to go over all the cells to get them to change to the new colour. Is there any way of adding to the code that will refresh the column. The code I have in is:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim WatchRange As Range
If Target.Cells.Count > 1 Then Exit Sub
If Target = "" Then
Target.Interior.Color = RGB(255, 255, 255) 'no color
Target.Font.Color = RGB(0, 0, 0)
Exit Sub
Else
CellVal = Target
Set WatchRange = Range("C2:C200")
If Not Intersect(Target, WatchRange) Is Nothing Then
If CellVal = "UK-S" Then
Target.Interior.Color = RGB(153, 204, 0) 'green
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "UK-L" Then
Target.Interior.Color = RGB(0, 204, 255) 'blue
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "UK-B" Then
Target.Interior.Color = RGB(255, 102, 0) 'red
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "France" Then
Target.Interior.Color = RGB(255, 153, 204) 'pink
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "Italy" Then
Target.Interior.Color = RGB(255, 209, 159) 'orange
Target.Font.Color = RGB(0, 0, 0) 'black
ElseIf CellVal = "E1" Then
Target.Interior.Color = RGB(0, 0, 255) 'blue
Target.Font.Color = RGB(255, 255, 255) 'white
ElseIf CellVal = "C" Then
Target.Interior.Color = RGB(255, 255, 255) 'white
Target.Font.Color = RGB(255, 0, 0) 'red
End If
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim WatchRange As Range
If Target.Cells.Count > 1 Then Exit Sub
If Target = "" Then
Target.Interior.Color = RGB(255, 255, 255) 'no color
Target.Font.Color = RGB(0, 0, 0)
Exit Sub
Else
CellVal = Target
Set WatchRange = Range("C2:C200")
If Not Intersect(Target, WatchRange) Is Nothing Then
If CellVal = "UK-S" Then
Target.Interior.Color = RGB(153, 204, 0) 'green
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "UK-L" Then
Target.Interior.Color = RGB(0, 204, 255) 'blue
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "UK-B" Then
Target.Interior.Color = RGB(255, 102, 0) 'red
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "France" Then
Target.Interior.Color = RGB(255, 153, 204) 'pink
Target.Font.Color = RGB(0, 0, 0)
ElseIf CellVal = "Italy" Then
Target.Interior.Color = RGB(255, 209, 159) 'orange
Target.Font.Color = RGB(0, 0, 0) 'black
ElseIf CellVal = "E1" Then
Target.Interior.Color = RGB(0, 0, 255) 'blue
Target.Font.Color = RGB(255, 255, 255) 'white
ElseIf CellVal = "C" Then
Target.Interior.Color = RGB(255, 255, 255) 'white
Target.Font.Color = RGB(255, 0, 0) 'red
End If
End If
End If
End Sub