PC Review


Reply
Thread Tools Rate Thread

Change cell color for more than 3 conditional statements

 
 
=?Utf-8?B?S2F0aWU=?=
Guest
Posts: n/a
 
      5th Mar 2007
I need to change the cell color for more than 3 conditional statements. How
do I do this?
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      5th Mar 2007
VBA.


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10" '<=== change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 1: .Interior.ColorIndex = 3 'red
Case 2: .Interior.ColorIndex = 6 'yellow
Case 3: .Interior.ColorIndex = 5 'blue
Case 4: .Interior.ColorIndex = 10 'green
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Katie" <(E-Mail Removed)> wrote in message
news:24816695-F6FA-4B42-991D-(E-Mail Removed)...
>I need to change the cell color for more than 3 conditional statements.
>How
> do I do this?



 
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
How to change the color of a cell using conditional formatting? LeBeauf8331 Microsoft Excel New Users 1 7th Jan 2010 11:14 PM
Useing IF statements to change a cell color edward/ Microsoft Excel Misc 1 4th Dec 2009 04:08 PM
Cell color change without using conditional formatting =?Utf-8?B?VHJlc2U=?= Microsoft Excel Misc 2 26th Aug 2005 06:00 PM
Conditional change to cell color =?Utf-8?B?UmljaGFyZA==?= Microsoft Excel Misc 3 13th Dec 2004 05:03 PM
Conditional Cell color change Todd Huttenstine Microsoft Excel Programming 3 24th Nov 2003 02:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:16 AM.