Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting / Condition Help ?? Kim Excel Discussion (Misc queries) 9 September 24th 09 03:59 PM
code to check condition for each row Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 3 February 10th 09 08:07 PM
Condition Formatting in code. How? Barb Reinhardt Excel Programming 0 August 11th 06 02:28 PM
I need 4 condition for condition formatting SeeKY Excel Programming 2 June 7th 05 09:41 AM
Condition added to Sort Code Todd Huttenstine[_3_] Excel Programming 1 January 2nd 04 09:35 AM


All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"