Excel 2003 cell background color

  • Thread starter Thread starter Dan E
  • Start date Start date
D

Dan E

Is there a way in Excel 2003 to have specific text content of cells set the
color of the background? e.g. all cells containing "RA" have a light green
background, "RB" have light blue.... etc., for a small set of text values.
TIA

Dan
 
Dan

Conditional Formatting will give you 4 formats including the default format.

Look under Format>CF and Cell Value is:


Gord Dibben Excel MVP
 
Many thanks, Gord - that will give me a good start. Is there anything I
might do with a macro, that might for example examine the cell contents then
set the color depending on what it finds?

Thanks again,

Dan
 
Dan

Adjust text and colors to suit and just keep adding "Cases" until you're
happy.

Note: as written, will find only whole text.

e.g. "my cat eats snakes" would not be formatted.

Sub Color_Text()
Dim Cell As Range
Dim col As Integer
On Error GoTo ws_exit
For Each Cell In Selection
Select Case LCase(Cell.Value)
Case "dog": col = 1
Case "cat": col = 5
Case "snake": col = 10
Case "bird": col = 19
Case "fish": col = 20
Case Else: col = 3
End Select
Cell.Interior.ColorIndex = col
Next
ws_exit:
End Sub


Gord
 
That looks pretty neat - thanks, Gord.

Dan
Gord Dibben said:
Dan

Adjust text and colors to suit and just keep adding "Cases" until you're
happy.

Note: as written, will find only whole text.

e.g. "my cat eats snakes" would not be formatted.

Sub Color_Text()
Dim Cell As Range
Dim col As Integer
On Error GoTo ws_exit
For Each Cell In Selection
Select Case LCase(Cell.Value)
Case "dog": col = 1
Case "cat": col = 5
Case "snake": col = 10
Case "bird": col = 19
Case "fish": col = 20
Case Else: col = 3
End Select
Cell.Interior.ColorIndex = col
Next
ws_exit:
End Sub


Gord
 
Back
Top