Select Case within IF-Else statement
Sorry, I posted the wrong code. When I run this code, the SELECT CASE
line gives me an error.
'-------------------------------------------------
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 rngTopLeft.Value < Date Then
.Interior.Pattern = xlGray50
Else
.Interior.Pattern = xlSolid
End If
If rngTopLeft.Value = 1 And rngTopLeft.Interior.ColorIndex = 15
Then
Select Case Weekday(rngTopLeft.Value)
Case 1, 7 'Sunday or saturday
.Interior.ColorIndex = 37
Case Else
.Interior.ColorIndex = 40
End Select
End If
If rngTopLeft.Value = "" Then
.Interior.ColorIndex = 15
End If
End With
End sub
|