View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Ardus Petus Ardus Petus is offline
external usenet poster
 
Posts: 718
Default Loop for if then calculation

You original code does not perform what your comments say.

I re-wrote the code according to your comments.

HTH
--
AP

'----------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call colors

End Sub
Sub colors()

Dim iRow As Long
Dim iCol As Long

For iRow = Range("F7").Row To Range("R42").Row Step 7
For iCol = Range("F7").Column To Range("R42").Column Step 2
doRange Cells(iRow, iCol)
Next iCol
Next iRow


End Sub


Sub doRange(rngTopLeft As Range)

With rngTopLeft.Resize(7, 2)
'If range is less than current date then cell shading.
If rngTopLeft.Value < Date Then
.Interior.Pattern = xlGray50
Else
.Interior.Pattern = xlSolid
End If
'if range has a no value then grey
If rngTopLeft.Value = "" Then
.Interior.ColorIndex = 15
Else
'color blue/beige (37 for weekend, 40 for weekday)
Select Case Weekday(rngTopLeft.Value)
Case 1, 7 'Sunday or saturday
.Interior.ColorIndex = 37
Case Else
.Interior.ColorIndex = 40
End Select
End If
End With
End Sub
'-------------------------------------

"rwnelson" a écrit dans le message de
ups.com...
Try this and again, thank you for all of your help

http://cjoint.com/?dmu71H4YXW