Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Excel confusion

I need to program a column to have a grey background if the top cell in that
column is either a Saturday or a Sunday, but I still need to be able to enter
data in the cells of that column. If the top cell in the column is a weekday,
the column should have no background color.

Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel confusion

Sub ColorColumns()
Dim cell as Range
for each cell in Range("A1:Z1")
if isdate(cell) then
if weekday(cell,vbMonday) 5 then
cell.EntireColumn.Interior.ColorIndex = 15
else
cell.EntireColumn.Interior.ColorIndex = xlNone
end if
end if
Next
End Sub

Change A1:Z1 to reflect the range of cells you want to check.


--
Regards,
Tom Ogilvy


"Syrena" wrote in message
...
I need to program a column to have a grey background if the top cell in
that
column is either a Saturday or a Sunday, but I still need to be able to
enter
data in the cells of that column. If the top cell in the column is a
weekday,
the column should have no background color.

Is this possible?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Excel confusion

Hi,

In addition to code as Tom suggested, you could also do this with
conditional formating.

Say you want to do this in column C. Select cell C1 and goto Format
-Conditional Formating. Let the condition be Formula Is

=OR(UPPER($C$1) = "SATURDAY",UPPER($C$1) = "SUNDAY")

then select the desired shade of grey for the corresponding format. Now
- with C1 selected, double click on the Format Painter icon (the
paintbrush) and then select all of column C - press enter then esc.

Hope that helps

-semiopen

Syrena wrote:
I need to program a column to have a grey background if the top cell in that
column is either a Saturday or a Sunday, but I still need to be able to enter
data in the cells of that column. If the top cell in the column is a weekday,
the column should have no background color.

Is this possible?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Excel confusion

A quick follow up:

If your cell header is in date form like 9/29/2006 you could replace
the condition by
=WEEKDAY($C$1,2) 5.

semiopen wrote:
Hi,

In addition to code as Tom suggested, you could also do this with
conditional formating.

Say you want to do this in column C. Select cell C1 and goto Format
-Conditional Formating. Let the condition be Formula Is

=OR(UPPER($C$1) = "SATURDAY",UPPER($C$1) = "SUNDAY")

then select the desired shade of grey for the corresponding format. Now
- with C1 selected, double click on the Format Painter icon (the
paintbrush) and then select all of column C - press enter then esc.

Hope that helps

-semiopen

Syrena wrote:
I need to program a column to have a grey background if the top cell in that
column is either a Saturday or a Sunday, but I still need to be able to enter
data in the cells of that column. If the top cell in the column is a weekday,
the column should have no background color.

Is this possible?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting confusion - Excel 2003 Ann Scharpf Excel Discussion (Misc queries) 3 March 16th 10 07:54 PM
SUMIF() confusion (Excel 2003) Ann Scharpf Excel Worksheet Functions 3 February 26th 10 04:06 PM
confusion about upgrade to excel 2007 J. DeHullu Setting up and Configuration of Excel 1 September 29th 07 08:44 AM
grid confusion with excel shadaab Excel Discussion (Misc queries) 1 October 19th 05 12:20 AM
Validation Confusion-Excel 2003 Shirley Zaknich Excel Discussion (Misc queries) 2 August 17th 05 01:51 AM


All times are GMT +1. The time now is 05:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"