Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Formating Specific Text
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? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Formating Specific Text
This is great! Thank you.
One more question: I just need it to do it for one column. How do I select the range? "Bernie Deitrick" wrote: 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? |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Formating Specific Text
Use after the Target.Cells.Count line:
'To apply the code to column A If Target.Column < 1 Then Exit Sub HTH, Bernie MS Excel MVP "andreabeas" wrote in message ... This is great! Thank you. One more question: I just need it to do it for one column. How do I select the range? "Bernie Deitrick" wrote: 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Nested formula to search a text string and return specific text | Excel Worksheet Functions | |||
Adding Dashes in front of text using text formating | Excel Discussion (Misc queries) | |||
CONDITIONAL FORMATING FINDING TEXT CONTAINING SPECIFIC NUMBERS | Excel Worksheet Functions | |||
conditional formating a specific amount of cells in a row. | New Users to Excel | |||
search a series of rows for a specific formating | Excel Worksheet Functions |