I have used the following code to apply conditional formatting in a spreadsheet.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
For Each myCell In Target
Select Case myCell.Value
Case Is = "Match"
Range(myCell, myCell.Offset(, 0)).Interior.ColorIndex = 27
Range(myCell, myCell.Offset(, -16)).Interior.ColorIndex = 27
Case Is = "QS"
Range(myCell, myCell.Offset(, 9)).Interior.ColorIndex = 45
Range(myCell, myCell.Offset(, -7)).Interior.ColorIndex = 45
Case Is = "MS"
Range(myCell, myCell.Offset(, 6)).Interior.ColorIndex = 45
Range(myCell, myCell.Offset(, -1)).Interior.ColorIndex = 45
Case Else
Range(myCell, myCell.Offset(, 6)).Interior.ColorIndex = xlNone
End Select
Next myCell
End Sub
It works perfectly if I type in the words "Match" or "QS". Is it possible to get the code to look at what is already in the cell?
Also Interior.ColorIndex changes the fill color what is the code to change the font color.
Many thanks, I look forward to hearing your ideas.
Cath
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myCell As Range
For Each myCell In Target
Select Case myCell.Value
Case Is = "Match"
Range(myCell, myCell.Offset(, 0)).Interior.ColorIndex = 27
Range(myCell, myCell.Offset(, -16)).Interior.ColorIndex = 27
Case Is = "QS"
Range(myCell, myCell.Offset(, 9)).Interior.ColorIndex = 45
Range(myCell, myCell.Offset(, -7)).Interior.ColorIndex = 45
Case Is = "MS"
Range(myCell, myCell.Offset(, 6)).Interior.ColorIndex = 45
Range(myCell, myCell.Offset(, -1)).Interior.ColorIndex = 45
Case Else
Range(myCell, myCell.Offset(, 6)).Interior.ColorIndex = xlNone
End Select
Next myCell
End Sub
It works perfectly if I type in the words "Match" or "QS". Is it possible to get the code to look at what is already in the cell?
Also Interior.ColorIndex changes the fill color what is the code to change the font color.
Many thanks, I look forward to hearing your ideas.
Cath