P
Peter Taylor
Dear Members
Hello, my name is Peter Taylor, from Swan Hill, Australia.
Which leads me to my next question. I am trying to create a simple
macro that when this macro is selected (or even better automatically
done when Excel is loaded) of highlighting a cell (from a range say of
A1:A100) that has the current date (6/11/2004). I have a long column
of dates eg:
5/11/2004 Friday
6/11/2004 Saturday
7/11/2004 Sunday
8/11/2004 Monday
9/11/2004 Tuesday
10/11/2004 Wednesday
11/11/2004 Thursday
12/11/2004 Friday
13/11/2004 Saturday
14/11/2004 Sunday
So as each new day comes around the date column (the current date)
cell is highlighted. I have tried some different codes, but whatever I
try VBA doesn't like the Today() function, but strangely enough likes
the Now() function, only problem there is that Now() also has the
minutes, hours etc.
Here is an example of what I have been trying to do.
Sub CalculateNewDays()
'For Each cell_in_loop In Range("C349:C649")
'If cell_in_loop.Value = Today() Then
' With cell_in_loop.Offset(0, 0).Interior
' .ColorIndex = 11
' .Pattern = xlSolid
' End With
'Selection.Font.ColorIndex = 2
'End If
'Next
For Each cell In Selection
If cell.Value = today() Then cell.Font.Color = vbBlue
Next cell
End Sub
Any help or assistance would be greatly appreciated.
Regards Peter Taylor, Australia
Hello, my name is Peter Taylor, from Swan Hill, Australia.
Which leads me to my next question. I am trying to create a simple
macro that when this macro is selected (or even better automatically
done when Excel is loaded) of highlighting a cell (from a range say of
A1:A100) that has the current date (6/11/2004). I have a long column
of dates eg:
5/11/2004 Friday
6/11/2004 Saturday
7/11/2004 Sunday
8/11/2004 Monday
9/11/2004 Tuesday
10/11/2004 Wednesday
11/11/2004 Thursday
12/11/2004 Friday
13/11/2004 Saturday
14/11/2004 Sunday
So as each new day comes around the date column (the current date)
cell is highlighted. I have tried some different codes, but whatever I
try VBA doesn't like the Today() function, but strangely enough likes
the Now() function, only problem there is that Now() also has the
minutes, hours etc.
Here is an example of what I have been trying to do.
Sub CalculateNewDays()
'For Each cell_in_loop In Range("C349:C649")
'If cell_in_loop.Value = Today() Then
' With cell_in_loop.Offset(0, 0).Interior
' .ColorIndex = 11
' .Pattern = xlSolid
' End With
'Selection.Font.ColorIndex = 2
'End If
'Next
For Each cell In Selection
If cell.Value = today() Then cell.Font.Color = vbBlue
Next cell
End Sub
Any help or assistance would be greatly appreciated.
Regards Peter Taylor, Australia