Formating Specific Text
Andrea,
Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears. You will need to add the "Etc." in the same manner as shown, ans select the
background colors. Note that the second value on one line is the first value on the next -
otherwise, some values will fall in the cracks.
HTH,
Bernie
MS Excel MVP
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myVal As String
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo NotString
myVal = UCase(Target.Value)
If myVal = "A" And myVal <= "CALD" Then Target.Interior.ColorIndex = 3
If myVal "CALD" And myVal <= "EG" Then Target.Interior.ColorIndex = 5
If myVal "EG" And myVal <= "HALL" Then Target.Interior.ColorIndex = 9
'Etc....
NotString:
End Sub
"andreabeas" wrote in message
...
I need to be able to assign colors to cells depending on what text is inputted.
If a name start with letters between:
A - Cald (I want the cell to be Yellow)
Call - Eg (I want the cell to be Black)
Ek - Hall (I want the cell to be Red)
Etc.....
Can someone please help?
|