Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional Formatting confusion - Excel 2003 | Excel Discussion (Misc queries) | |||
SUMIF() confusion (Excel 2003) | Excel Worksheet Functions | |||
confusion about upgrade to excel 2007 | Setting up and Configuration of Excel | |||
grid confusion with excel | Excel Discussion (Misc queries) | |||
Validation Confusion-Excel 2003 | Excel Discussion (Misc queries) |