ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Conditional format for 5 numbers (https://www.excelbanter.com/excel-discussion-misc-queries/150699-conditional-format-5-numbers.html)

CINDY

Conditional format for 5 numbers
 
How do I get 1-5 entered as a value to format with each five numbers having
its own background color?

CINDY

Conditional format for 5 numbers in Excel 2003
 


"Cindy" wrote:

How do I get 1-5 entered as a value to format with each five numbers having
its own background color?


Peo Sjoblom

Conditional format for 5 numbers in Excel 2003
 
If you have excel 2007 you can use conditional formatting, earlier versions
would need VBA


http://www.xldynamic.com/source/xld.....Download.html

--
Regards,

Peo Sjoblom



"Cindy" wrote in message
...


"Cindy" wrote:

How do I get 1-5 entered as a value to format with each five numbers
having
its own background color?




Gord Dibben

Conditional format for 5 numbers
 
You want this for one cell with a choice of 5 numbers?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A1"))
' for a range use "A1:A10" or similar
On Error GoTo endit
Application.EnableEvents = False
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
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 into that sheet module.


Gord Dibben MS Excel MVP

On Wed, 18 Jul 2007 07:46:12 -0700, Cindy
wrote:

How do I get 1-5 entered as a value to format with each five numbers having
its own background color?



CINDY

Conditional format for 5 numbers in Excel 2003
 
Thank you; this worked great!

"Peo Sjoblom" wrote:

If you have excel 2007 you can use conditional formatting, earlier versions
would need VBA


http://www.xldynamic.com/source/xld.....Download.html

--
Regards,

Peo Sjoblom



"Cindy" wrote in message
...


"Cindy" wrote:

How do I get 1-5 entered as a value to format with each five numbers
having
its own background color?






All times are GMT +1. The time now is 07:21 PM.

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