Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2007

Tip: Looking for answers? Try searching our database.

how do i set more than three conditions in condition formatting?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
senpm - 09 Dec 2007 13:04 GMT
I need to set up color coding for five different conditions - can you help me?
if A1 cell value is greater than or equal to 6 then color yellow
if A1 cell value is between 5 and 6 then color silver
if A1 cell value is between 4 and 5 then color blue
if A1 cell value is less than 4 then color red
if A1 cell value has no value (entered) then color cyan

can we do this with conditional formatting or do we need VB for this? if vb
is needed can i get some idea how to create the code...

i am not good at coding...please help me....
Bob Phillips - 09 Dec 2007 14:08 GMT
You need 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 "":        .Interior.ColorIndex = 34 'light turquoise
               Case 6:         .Interior.ColorIndex = 6  'yellow
               Case Is >= 5:   .Interior.ColorIndex = 15 'gray 25%
               Case Is >= 4:   .Interior.ColorIndex = 5  'blue
               Case Else:      .Interior.ColorIndex = 3  'red
           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.

Signature

HTH

Bob

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

>I need to set up color coding for five different conditions - can you help
>me?
[quoted text clipped - 9 lines]
>
> i am not good at coding...please help me....

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.