PC Review


Reply
Thread Tools Rate Thread

Condition Formatting Code for text in cells

 
 
=?Utf-8?B?VG9ueQ==?=
Guest
Posts: n/a
 
      31st Oct 2007
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 With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      31st Oct 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Condition formatting based on other cells values =?Utf-8?B?TWFyY28=?= Microsoft Excel Discussion 3 2nd Aug 2007 04:20 PM
Re: Condition Formatting in code. How? Corey Microsoft Excel Programming 1 11th Aug 2006 03:18 PM
Re: Condition Formatting in code. How? raypayette Microsoft Excel Programming 1 11th Aug 2006 02:55 PM
RE: Condition Formatting in code. How? =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 0 11th Aug 2006 02:28 PM
Copying condition formatting cells only Richard Flint Microsoft Excel Worksheet Functions 1 21st Oct 2003 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:29 AM.