Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default Condition Formatting Code for text in cells

I have a workbook that consists of monthly calenders that uses single text
characters in cells that I want to automatically convert to a specific colour
when entered in a range in each worksheet. I am familiar with conditional
formatting but have more than three different formats. I need some basic vba
code to colour the cells that match the following entire cell contents:

Dog Purple
Cat Blue
M Red
O Yellow
V Green

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Condition Formatting Code for text in cells

Let's say the cells are in column A. Try the following worksheet event macro:

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("A:A")
If Intersect(Target, r) Is Nothing Then Exit Sub
With Target
Select Case .Value
Case "Dog"
.Interior.ColorIndex = 39
Case "Cat"
.Interior.ColorIndex = 5
Case "M"
.Interior.ColorIndex = 3
Case "O"
.Interior.ColorIndex = 6
Case "V"
.Interior.ColorIndex = 10
End Select
End With
End Sub
--
Gary''s Student - gsnu200752


"Tony" wrote:

I have a workbook that consists of monthly calenders that uses single text
characters in cells that I want to automatically convert to a specific colour
when entered in a range in each worksheet. I am familiar with conditional
formatting but have more than three different formats. I need some basic vba
code to colour the cells that match the following entire cell contents:

Dog Purple
Cat Blue
M Red
O Yellow
V Green

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
VBA Code; need linked cells to change color if condition met JVANWORTH Excel Worksheet Functions 26 September 13th 07 01:01 PM
Condition Formatting - Work Sheet Event Code Danny Excel Programming 7 September 13th 06 07:05 PM
Condition Formatting in code. How? Corey Excel Programming 1 August 11th 06 03:18 PM
Condition Formatting in code. How? raypayette[_45_] Excel Programming 1 August 11th 06 02:55 PM
Condition Formatting in code. How? Barb Reinhardt Excel Programming 0 August 11th 06 02:28 PM


All times are GMT +1. The time now is 06:47 AM.

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

About Us

"It's about Microsoft Excel"