![]() |
date references in macros
I am trying to set some formatting perameters in a macro for a calendar. I
would like to base the formatting on month. For example, if the month is January color all the day cells blue, if February red, etc. I have only been able to get my macro to shade a range and it does it all in 1 color. I am obviously using the wrong language/terms but I can't find info on how to fix. Suggestions Please. John |
date references in macros
Look at Format = Conditional Formatting
if you only have 3 conditions Otherwise For each cell in Selection Select Case month(cell.Value) Case 1 ' January cell.Interior.ColorIndex = 5 Case 2 ' February cell.Interior.ColorIndex = 3 Case 3 ' March cell.Interior.ColorIndex = 4 .. . . End Select Next cell -- Regards, Tom Ogilvy "blue49" wrote in message ... I am trying to set some formatting perameters in a macro for a calendar. I would like to base the formatting on month. For example, if the month is January color all the day cells blue, if February red, etc. I have only been able to get my macro to shade a range and it does it all in 1 color. I am obviously using the wrong language/terms but I can't find info on how to fix. Suggestions Please. John |
date references in macros
Thank you Tom,
This works perfect! The conditional formatting does not work as I want all 12 months. The macro though, is exactly what I wanted. I have one other question you might be able to help with. I always seem to have trouble with the formats in macros. if I wanted to use a date range such as 1/01/2006 to 1/15/2006, what symbols or language will use in the macro for it to recognize that exact range? Would you use = or <=, or is there some other way that it should be phrased? Again, thanks for your help. John "Tom Ogilvy" wrote: Look at Format = Conditional Formatting if you only have 3 conditions Otherwise For each cell in Selection Select Case month(cell.Value) Case 1 ' January cell.Interior.ColorIndex = 5 Case 2 ' February cell.Interior.ColorIndex = 3 Case 3 ' March cell.Interior.ColorIndex = 4 .. . . End Select Next cell -- Regards, Tom Ogilvy "blue49" wrote in message ... I am trying to set some formatting perameters in a macro for a calendar. I would like to base the formatting on month. For example, if the month is January color all the day cells blue, if February red, etc. I have only been able to get my macro to shade a range and it does it all in 1 color. I am obviously using the wrong language/terms but I can't find info on how to fix. Suggestions Please. John |
date references in macros
for each cell in Selection
if cell.Value = DateSerial(2006,1,1) and _ cell.Value <= DateSerial(2006,1,15) then -- Regards, Tom Ogilvy "blue49" wrote in message ... Thank you Tom, This works perfect! The conditional formatting does not work as I want all 12 months. The macro though, is exactly what I wanted. I have one other question you might be able to help with. I always seem to have trouble with the formats in macros. if I wanted to use a date range such as 1/01/2006 to 1/15/2006, what symbols or language will use in the macro for it to recognize that exact range? Would you use = or <=, or is there some other way that it should be phrased? Again, thanks for your help. John "Tom Ogilvy" wrote: Look at Format = Conditional Formatting if you only have 3 conditions Otherwise For each cell in Selection Select Case month(cell.Value) Case 1 ' January cell.Interior.ColorIndex = 5 Case 2 ' February cell.Interior.ColorIndex = 3 Case 3 ' March cell.Interior.ColorIndex = 4 .. . . End Select Next cell -- Regards, Tom Ogilvy "blue49" wrote in message ... I am trying to set some formatting perameters in a macro for a calendar. I would like to base the formatting on month. For example, if the month is January color all the day cells blue, if February red, etc. I have only been able to get my macro to shade a range and it does it all in 1 color. I am obviously using the wrong language/terms but I can't find info on how to fix. Suggestions Please. John |
All times are GMT +1. The time now is 02:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com