View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default Changing color of cells

I'd suggest a slightly different approach:

Public Sub Working()
Dim response As Long
response = MsgBox("Do you work the first weekend?", vbYesNo)
With Range("A2:D53").FormatConditions
.Delete
.Add Type:=xlExpression, _
Formula1:="=MOD(ROW(C3),2)=" & 1 + (response = vbYes)
.Item(1).Font.Color = vbBlue
End With
End Sub

This allows you to add or subtract rows and maintain the font color.


In article ,
"Carl Brehm" wrote:

Need to change color of every other row, but only that portion of row in
the range.
Here is what I have.


Sub working()
Dim x As Integer
Dim response
response = MsgBox("Do you Work the first weekend?", vbYesNo)
If response = vbYes Then
x = 0
Else
x = 1
End If

With Worksheets("Yearly Planner")
For Each cell In .Range("A2:D53")
With cell
If x = 0 Then
.Font.Color = vbBlue ' working weekend
Else
.Font.Color = black 'off weekend
End If
End With

' does Excel go to next cell in row or in column?


End Sub

Thanks Carl