Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested formula to search a text string and return specific text Barbie Excel Worksheet Functions 10 February 21st 09 07:40 AM
Adding Dashes in front of text using text formating Neal Excel Discussion (Misc queries) 1 November 27th 06 10:58 PM
CONDITIONAL FORMATING FINDING TEXT CONTAINING SPECIFIC NUMBERS Twiggy Excel Worksheet Functions 4 April 12th 06 09:13 AM
conditional formating a specific amount of cells in a row. jeff New Users to Excel 3 April 4th 06 06:07 PM
search a series of rows for a specific formating Harris Excel Worksheet Functions 2 July 30th 05 11:46 PM


All times are GMT +1. The time now is 12:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"