Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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






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
cell references in macros Dave F Excel Discussion (Misc queries) 3 November 28th 06 05:19 PM
Column References in Macros Brendan Vassallo Excel Discussion (Misc queries) 2 September 5th 06 11:53 PM
How do I use absolute references in macros? Michael Excel Programming 2 January 18th 06 04:42 PM
Relative References for macros Grace[_4_] Excel Programming 5 June 10th 04 06:09 PM
References in VBA macros ? KajBre Excel Programming 3 October 28th 03 01:43 PM


All times are GMT +1. The time now is 02:14 AM.

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

About Us

"It's about Microsoft Excel"