![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: Hong Kong
Posts: 5
|
Can I have more than 3 conditions for the conditional formatting function?
|
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
|
|
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
[ This Message was edited by: Mark W. on 2002-04-24 11:23 ] |
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Helena, MT
Posts: 13,690
|
Actually, depending on the type of conditions you have, you may be able to trick excel into giving you more formats by combining custom formatting with conditional formatting. As an example
Say you want the following formatting for a range of cells Value Color <5 Black 5-9 Green 10-14 Blue 15-19 Cyan 20-24 Purple 25+ Red Select your range and Under format, choose custom and enter [<5][Black]0;[<10][Green]0;[<15][Blue]0 Now under conditional formatting enter Condition 1 Cell Value >=25 Format Red Condition 2 Cell Value >=20 Format Purple Condition 3 Cell Value >=15 Format Cyan This will give you 6 conditional formats for your range. |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Posts: 104
|
It's not working. It does not like the formula.
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,385
|
You can do this with VBA as Aladin, Mark, and lenze suggested. Here is a simple example, although your question was not clear as to whether your data is numeric, text, dates, etc. This code uses a select case structure for cell A1's interior color index (cell shading), depending on what number is entered into A1. You can expand the conditions as needed.
Right click on your sheet tab, left click on View Code, and paste this in: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address <> "$A$1" Or Target.Cells.Count > 1 Then Exit Sub Select Case [A1].Value Case 1 Target.Interior.ColorIndex = 3 Case 2 Target.Interior.ColorIndex = 6 Case 3 Target.Interior.ColorIndex = 8 Case 4 Target.Interior.ColorIndex = 22 Case 5 Target.Interior.ColorIndex = 25 Case Else Target.Interior.ColorIndex = 15 End Select End Sub Is this any help for what you were requesting? |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2005
Posts: 52
|
Right the VBA code works a treat..thanks for that.
Instead of keying in "SB" = colour on the VBA code could it be linked to cell references so you opnly have to change the "SB" to a "BA" and it'll still change colour? Hope that makes sense? |
|
|
|
|
|
#8 |
|
New Member
Join Date: Nov 2006
Posts: 1
|
I need to be able to colour a row depending on the value of the element in the first column of the row. I need 4 different colours and with excel's capabilities i can only have 3 colours. So i need to have a vb part. It needs to be dynamic though.. Values are numeric and text strings. Can you inform me about the function that colours the whole row? and something else.. Inside the case function what is the dynamic declaration of the row? It my first time with excel..
Thanx |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Mar 2006
Posts: 443
|
Hi Lenze,
Just reading your reply, can you tell me where the custom is on format. You wrote: Select your range and Under format, choose custom and enter Thanks Ian |
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Helena, MT
Posts: 13,690
|
Hi:
It's under Format>Cells on the Number Tab. It's one of the options in the category list. When you select it, enter the formula in the Type field. lenze
__________________
If you have to tell your boss you're good with Excel, you're NOT!! All I know about Excel I owe to my ignorance! Scotch: Because you don't solve great Excel problems over white wine |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|