View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
StargateFan[_3_] StargateFan[_3_] is offline
external usenet poster
 
Posts: 171
Default Colouring cells based on day of week?

On Sat, 8 Mar 2008 19:20:01 -0800, Joel
wrote:

You can use conditional formating. Use formula is

the weekday function will return 1 for Sunday and 7 for Saturday

=(or(weekday(A5)=1,weekday(A5)=7))


This is awesome, it works fantastically!

I just ran into one small glitch. I don't know why and I've checked
very carefully, but even when the first row is empty, it shows the
conditional formatting alternate colour. Now once I change the date
it behaves properly and is clear if not a weekend day, but the
instance A5, in this case, is empty, the row gets weekend colouring
back in even though no date is specified.

I know it's most likely tied into the unanticipated fact that A5 is
the only cell in the entire sheet that doesn't contain a formula (?).
Since it's the source cell for the dates in the rest of the sheet, it
truly is blank when there has been no date input into it.

In other words, A5 may be completely blank, but A7 has this:
=IF($A$5<"",($A$5+1),"")
as well as the equivalent forumulas in A9, A11, A13, A15 and A17.
Anyway, I'm guessing that's why (?).

Would modifying the conditional formatting do the trick, do you think?
I'm not sure if this is the cause, it's just that it seems that
otherwise, it's a heck of a coincidental that the only difference
between cells is this and this is the afflicted row.

Thanks! :oD


"StargateFan" wrote:

Hi.

I have a spreadsheet that has these rows:
B4:G4
B6:G6
B8:G8
B10:G10
B12:G12
B14:G14
B16:G16

A5, A7, A9, A11, A13, A15 and A17 (1 week, 7 days) have the date input
for each row, which can be changed via a macro requesting user input.

Is there a way to get the row cells B:5 above to change colour for the
2 rows that end up corresponding to Saturday and Sunday?

i.e., if user starts the week at Weds. in A5 then Saturday falls on
row B10:G10, and Sunday is B12:G12, etc.

Sorry, it's a bit difficult to describe in words but hopefully I've
made it clear enough. thx