ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Conditional Formatting (https://www.excelbanter.com/excel-discussion-misc-queries/170259-conditional-formatting.html)

yclhk

Conditional Formatting
 
How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays in a
designated format.

David Biddulph[_2_]

Conditional Formatting
 
If you do mean that you want one designated format if the cell value is A,
B, C, D, or E, then you can use an OR function in your conditional
formatting condition. Use Formula Is, not Cell Value Is.
--
David Biddulph

"yclhk" wrote in message
...
How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays in
a
designated format.




Gary

Conditional Formatting
 
I use a For-Next loop for this.

Place code behind worksheet -

Presumes your data is in Column G, rows 2-500

For rwIndex = 2 To 500
For colIndex = 6 To 6
With Worksheets("Your Tab Name").Cells(rwIndex, colIndex)
If .Value = "A" Then
.Font.ColorIndex = 3
Else
If .Font.ColorIndex = B Then
.Font.ColorIndex = 4
Else

End If
End If
End With
Next colIndex
Next rwIndex


hth

"yclhk" wrote:

How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays in a
designated format.


Gord Dibben

Conditional Formatting
 
You could use event code to get more than 3 formats for a cell.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Range
Set vRngInput = Intersect(Target, Range("A1"))
If vRngInput Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
For Each rng In vRngInput
'Determine the color
Select Case UCase(rng.Value)
Case Is = "A": Num = 10 'green
Case Is = "B": Num = 1 'black
Case Is = "C": Num = 5 'blue
Case Is = "D": Num = 7 'magenta
Case Is = "E": Num = 46 'orange
Case Is = "F": Num = 3 'red
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
endit:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into that sheet module. Alt + q to go back to Exel window.

Adjust range and colors to suit.


Gord Dibben MS Excel MVP

On Wed, 19 Dec 2007 08:56:01 -0800, yclhk
wrote:

How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays in a
designated format.



yclhk

Conditional Formatting
 
Thanks for all. I think the solution of using OR function is more simple.
However, how to compose the formula in this formatting ?

Thanks again for your help,

"David Biddulph" wrote:

If you do mean that you want one designated format if the cell value is A,
B, C, D, or E, then you can use an OR function in your conditional
formatting condition. Use Formula Is, not Cell Value Is.
--
David Biddulph

"yclhk" wrote in message
...
How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays in
a
designated format.





Stephen[_2_]

Conditional Formatting
 
For conditionally formatting cell A1, use
=OR(A1="A",A1="B",A1="C",A1="D",A1="E")

"yclhk" wrote in message
...
Thanks for all. I think the solution of using OR function is more simple.
However, how to compose the formula in this formatting ?

Thanks again for your help,

"David Biddulph" wrote:

If you do mean that you want one designated format if the cell value is
A,
B, C, D, or E, then you can use an OR function in your conditional
formatting condition. Use Formula Is, not Cell Value Is.
--
David Biddulph

"yclhk" wrote in message
...
How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays
in
a
designated format.







yclhk

Conditional Formatting
 
Thanks to Stephen, it works.

"Stephen" wrote:

For conditionally formatting cell A1, use
=OR(A1="A",A1="B",A1="C",A1="D",A1="E")

"yclhk" wrote in message
...
Thanks for all. I think the solution of using OR function is more simple.
However, how to compose the formula in this formatting ?

Thanks again for your help,

"David Biddulph" wrote:

If you do mean that you want one designated format if the cell value is
A,
B, C, D, or E, then you can use an OR function in your conditional
formatting condition. Use Formula Is, not Cell Value Is.
--
David Biddulph

"yclhk" wrote in message
...
How to include more than 3 conditions for formatting the cell ?
For example: if the cell values are A, B, C, D or E, the cell displays
in
a
designated format.








All times are GMT +1. The time now is 11:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com