can I color true or false results differently in excel

J

JT

I want to identify the day of the week in my spreadsheet and have used the
formula

=IF(WEEKDAY(L2)=1,"SU",IF(WEEKDAY(L2)=2,"M",IF(WEEKDAY(L2)=3,"T",IF(WEEKDAY(L2)=4,"W",IF(WEEKDAY(L2)=5,"TH",IF(WEEKDAY(L2)=6,"F",IF(WEEKDAY(L2)=7,"SA","")))))))

where the L2 cell would have a date (ie 04/10/2008) but would like the
weekdays (M-F) to be black and have SA and SU come up red. any ideas /
suggestions?
 
M

Mike

Paste this code into the worksheet that your formula is in
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range("B2")
Select Case .Value
Case "M", "T", "W", "TH", "F"
.Interior.ColorIndex = 1
.Font.ColorIndex = 2
Case "SA", "SU"
.Interior.ColorIndex = 3
.Font.ColorIndex = 2
Case Else
.Interior.ColorIndex = 2
.Font.ColorIndex = 1
End Select
End With
End Sub
 
J

JT

I think that both of you guys are WAY ABOVE my programming level. Thanks for
the help but I think I should have put my question in the beguinners category
since I really don't know what conditional formatting is let alone how to do
it.

sorry to waste your time.
JT
 
J

JT

I think that both of you guys are WAY ABOVE my programming level. Thanks for
the help but I think I should have put my question in the beguinners
category. I have tried to copy the subroutine that you sent to several cells
in my worksheet and either get text of the subroutine or, if I start it with
"=" and the subroutine all in one cell, excell calls an error and highlights
the term ".value" in the subroutine. I have also tried messing with the With
Range("B2") line and tried both With Range(O20) {a cell that is Saturday} and
With Range(O2:O32) {the 31 cells to correspond to the 31 possible dates per
month} and had no luck.

Thanks for the effort.
sorry to waste your time.
JT
 
J

JT

Strike my reply to your answer Mark. I just found a link to conditional
formating and, WOW, what a powerful tool. Great suggestion! Now my weekdays
are black with Green background and the weekends are white with red
backgrounds. More than I had in mind.

If I did this right the link that I followed was
http://www.contextures.com/xlCondFormat01.html
if not, then this is the webpage I used. (Like I said, I am not much of a
programmer, typical 52 year old who didn't get his first computer till he was
40'ish)

Thanks again Mike.
JT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top