Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Condition Formatting in code. How?
I have got so far but i get an error now in this:
Sub Shades() worksheets("Print & Shading Page").Select Dim cell As Range Dim PSP As Worksheet For Each cell In worksheets("Print & Shading Page").Range("c8:r30") With cell If .Value < "" Then PSP.Range(.Address).Value = TODAY() < 1 With Selection.Interior .ColorIndex = 38 .Pattern = xlSolid End With Else End If If .Value < "" Then PSP.Range(.Address).Value = TODAY() < 14 With Selection.Interior .ColorIndex = 36 .Pattern = xlSolid End With Else End If If .Value < "" Then PSP.Range(.Address).Value = TODAY() < 30 With Selection.Interior .ColorIndex = 35 .Pattern = xlSolid End With Else End If If .Value < "" Then PSP.Range(.Address).Value = TODAY() 1 With Selection.Interior .ColorIndex = 2 .Pattern = xlSolid End With End If End With Next End Sub Any idea's where i am going wrong? Corey.... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Condition Formatting in code. How?
I couldn't really figure out what your conditions were, but this should get
your started. Sub Shades() Worksheets("Print & Shading Page").Select Dim cell As Range Dim PSP As Worksheet Set PSP = Worksheets("Print & Shading Page") For Each cell In PSP.Range("c8:r30") If cell.Value < "" Then If (cell.Value - Date) 30 Then With cell.Interior .ColorIndex = 35 .Pattern = xlSolid End With ElseIf (cell.Value - Date) 14 Then With cell.Interior .ColorIndex = 36 .Pattern = xlSolid End With ElseIf (cell.Value - Date) 1 Then With cell.Interior .ColorIndex = 38 .Pattern = xlSolid End With ElseIf (cell.Value - Date) < 1 Then With cell.Interior .ColorIndex = 2 .Pattern = xlSolid End With End If End If Next End Sub -- Regards, Tom Ogilvy "Corey" wrote: I have got so far but i get an error now in this: Sub Shades() worksheets("Print & Shading Page").Select Dim cell As Range Dim PSP As Worksheet For Each cell In worksheets("Print & Shading Page").Range("c8:r30") With cell If .Value < "" Then PSP.Range(.Address).Value = TODAY() < 1 With Selection.Interior .ColorIndex = 38 .Pattern = xlSolid End With Else End If If .Value < "" Then PSP.Range(.Address).Value = TODAY() < 14 With Selection.Interior .ColorIndex = 36 .Pattern = xlSolid End With Else End If If .Value < "" Then PSP.Range(.Address).Value = TODAY() < 30 With Selection.Interior .ColorIndex = 35 .Pattern = xlSolid End With Else End If If .Value < "" Then PSP.Range(.Address).Value = TODAY() 1 With Selection.Interior .ColorIndex = 2 .Pattern = xlSolid End With End If End With Next End Sub Any idea's where i am going wrong? Corey... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting / Condition Help ?? | Excel Discussion (Misc queries) | |||
code to check condition for each row | Excel Discussion (Misc queries) | |||
Condition Formatting in code. How? | Excel Programming | |||
I need 4 condition for condition formatting | Excel Programming | |||
Condition added to Sort Code | Excel Programming |