PC Review


Reply
Thread Tools Rate Thread

Colouring cells based on day of week?

 
 
StargateFan
Guest
Posts: n/a
 
      9th Mar 2008
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

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      9th Mar 2008
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))

"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
>
>

 
Reply With Quote
 
StargateFan
Guest
Posts: n/a
 
      9th Mar 2008
On Sat, 8 Mar 2008 19:20:01 -0800, Joel
<(E-Mail Removed)> 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! D

>
>"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
>>
>>


 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      9th Mar 2008
A date is just a number with 1 equalling Jan 1, 1900. I assume the blank is
returning a 0 which would be Dec 31,1899. Is this data a weekend???

"StargateFan" wrote:

> On Sat, 8 Mar 2008 19:20:01 -0800, Joel
> <(E-Mail Removed)> 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! D
>
> >
> >"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
> >>
> >>

>
>

 
Reply With Quote
 
StargateFan
Guest
Posts: n/a
 
      9th Mar 2008
On Sun, 9 Mar 2008 07:53:02 -0700, Joel
<(E-Mail Removed)> wrote:

>A date is just a number with 1 equalling Jan 1, 1900. I assume the blank is
>returning a 0 which would be Dec 31,1899. Is this data a weekend???


Not sure I understand the question, since the cell is absolutely blank
when there is no data in it. When user presses a "clear" button, 3
cells get emptied of all data which affects all the dates in the
sheet. A5 is one of the 3 cells. So after that there is nothing in
A5 at all, whereas the other date cells always have formulas similar
to this (I found it was easier working with absolutes, so that is only
change to original sheet's formulas):
=IF($A$5<>"",($A$5+1),"")
though there are no dates in these either, just the formula. So when
no data is in A5, the others clear. And CF carefully checked. I
changed it to absolutes, too, and copied each row and didn't type so
should be no typing errors there on my part.

Don't know what's up with this?? As I said, once a date is dumped
into A5, put there with input from user via macro, then it behaves
according to conditional formatting. Yet when emptied and all rows go
clear, this one remains with CF colour. Yet cells have actually no
colour of their own. Went back and made sure original cell colour is
clear. It's very odd. <g>

>"StargateFan" wrote:
>
>> On Sat, 8 Mar 2008 19:20:01 -0800, Joel
>> <(E-Mail Removed)> 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! D
>>
>> >
>> >"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
>> >>
>> >>

>>
>>


 
Reply With Quote
 
StargateFan
Guest
Posts: n/a
 
      9th Mar 2008
On Sun, 09 Mar 2008 10:13:38 -0500, StargateFan
<IDon'tAcceptSpam@IDon'tAcceptSpam.com> wrote:

>On Sun, 9 Mar 2008 07:53:02 -0700, Joel
><(E-Mail Removed)> wrote:
>
>>A date is just a number with 1 equalling Jan 1, 1900. I assume the blank is
>>returning a 0 which would be Dec 31,1899. Is this data a weekend???

>
>Not sure I understand the question, since the cell is absolutely blank
>when there is no data in it. When user presses a "clear" button, 3
>cells get emptied of all data which affects all the dates in the
>sheet. A5 is one of the 3 cells. So after that there is nothing in
>A5 at all, whereas the other date cells always have formulas similar
>to this (I found it was easier working with absolutes, so that is only
>change to original sheet's formulas):
>=IF($A$5<>"",($A$5+1),"")


[SNIP]

Fixed! My solution wasn't elegant or anthing and don't ask me why it
works, but it does the job. At some point just now, a flash bulb went
off. Since it was the CF that was affected by a blank cell, or it
seemed to be, then I just changed the formula to not depend on the
contents of the empty cell<duh>!

I changed
=(OR(WEEKDAY($A$5)=1,WEEKDAY($A$5)=7))
to
=(OR(WEEKDAY($A$7-1)=1,WEEKDAY($A$7-1)=7))
and presto. When A5 is blank, row B4:G4 is now clear of all colour.

Go figure ... D

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
colouring cells Joey Microsoft Word Document Management 1 20th May 2010 04:57 PM
Automatically copy cells from two week day sheets based from today MMs4MSU Microsoft Excel Misc 0 25th Nov 2009 03:23 PM
colouring cells that are between two dates Ian Microsoft Excel Programming 2 6th Sep 2005 08:49 PM
Colouring cells Sam A Microsoft Excel Programming 2 17th Aug 2004 03:27 PM
Colouring cells automatically Del Microsoft Excel New Users 7 22nd May 2004 05:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 PM.