Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hey i need a vba code for conditional formula .... i want to check
this 3 conditions for every cell through vba code ... = 120 then red colour <50 then orange inbetween 50 and 120 then yellow colour |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() This code should work. You have to limit the range otherwise to go through the entire worksheet takes a long time. There are more than one shade of the colors and I picked the Standard shade for each of the colors. Const RedColor = 3 Const YellowColor = 6 Const OrangeColor = 46 Set DataRange = Range("A1:D500") For Each cell In DataRange If cell < "" And IsNumeric(cell) Then Select Case cell Case Is < 50 cell.Interior.ColorIndex = OrangeColor Case Is < 120 cell.Interior.ColorIndex = YellowColor Case Else cell.Interior.ColorIndex = RedColor End Select End If Next cell -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=168094 Microsoft Office Help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi again Vicky,
Not sure if you need it but the code can be enhanced to only include numeric cells and exclude blank cells as below. Sub ConditFormat() '= 120 then red colour '<50 then orange 'inbetween 50 and 120 then yellow Dim c As Range 'Edit "Sheet1" to your sheet name With Sheets("Sheet1") For Each c In .UsedRange If c.Value < "" And _ IsNumeric(c.Value) Then Select Case c.Value Case Is = 120 c.Interior.ColorIndex = 3 Case Is < 50 c.Interior.ColorIndex = 46 Case 50 To 120 c.Interior.ColorIndex = 6 End Select End If Next c End With End Sub -- Regards, OssieMac |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks a lot !!!!!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to conditional format all black after date specified in code? | Excel Discussion (Misc queries) | |||
Code for conditional formula | Excel Programming | |||
Multiple conditional on conditional format formula | Excel Programming | |||
Multiple conditional on conditional format formula | Excel Programming | |||
Modify a conditional format formula in code? | Excel Programming |