Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default How can I set more than 3 conditions for cells?

I have a worksheet that I need to colour code the cells according to their
values and I need a total of 11 colours.

Conditional formatting only has up to 3 conditions and so I cannot use that
method.

Is there any other way that I can format my cells to automatically colour
code?

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default How can I set more than 3 conditions for cells?

Hi,

You could buy Excel 2007 or use the worksheet change event. In the sample
below I've done only 4 options but you can easilly extend this to 11. You
didn't say what values you wanted either but likewise you can easily alter
this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Select Case Target.Value
Case Is = 1
icolor = 3
Case Is = 2
icolor = 4
Case Is = 3
icolor = 5
Case Is = 4
icolor = 6
Case Else
icolor = xlNone
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub


Mike

"Cheng Joo" wrote:

I have a worksheet that I need to colour code the cells according to their
values and I need a total of 11 colours.

Conditional formatting only has up to 3 conditions and so I cannot use that
method.

Is there any other way that I can format my cells to automatically colour
code?

Thank you.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How can I set more than 3 conditions for cells?

Private Sub Worksheet_Change(ByVal Target As Range)
Set r = Range("A1:A10")
If Intersect(Target, r) Is Nothing Then
Exit Sub
End If
vals = Array("C", "D", "G", "H", "K", "L", "O", "S", "C", "X") 'your values
nums = Array(8, 9, 6, 3, 7, 4, 20, 10, 8, 15) 'edit colorindex numbers
For Each rr In r
icolor = 0
For i = LBound(vals) To UBound(vals)
If UCase(rr.Value) = vals(i) Then
icolor = nums(i)
End If
Next
If icolor 0 Then
rr.Interior.ColorIndex = icolor
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Sat, 12 Dec 2009 03:51:01 -0800, Cheng Joo
wrote:

I have a worksheet that I need to colour code the cells according to their
values and I need a total of 11 colours.

Conditional formatting only has up to 3 conditions and so I cannot use that
method.

Is there any other way that I can format my cells to automatically colour
code?

Thank you.


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
Using 2 cell CF conditions from different cells together j5b9721 Excel Worksheet Functions 2 August 23rd 09 09:13 PM
referencing cells based on conditions in other cells mirskman Excel Discussion (Misc queries) 1 January 29th 09 09:57 PM
trying to set conditions for a range of cells mike Excel Worksheet Functions 8 October 29th 08 11:27 PM
shade cells based on conditions - i have more than 3 conditions Mo2 Excel Worksheet Functions 3 March 30th 07 07:19 AM
Averaging Cells Based On Conditions in Neighboring Cells foofoo Excel Discussion (Misc queries) 3 June 21st 06 03:10 AM


All times are GMT +1. The time now is 03:10 PM.

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"