Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
ray ray is offline
external usenet poster
 
Posts: 54
Default Macro for Date If Statement

I have a column of Dates, need the Macro to look at all the date in the
column and compare to the current date and if the date in the column is more
that 365 days old want to turn the date in the column GREEN! Can this be
done? Currently there are over 500 dates in the column.

Thanks for your help
Ray
  #2   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Macro for Date If Statement

Column? Are the dates in a table? If so then the following will work (with
column1) of the table containing the cursor

Dim oCell As Cell
Dim oRng As Range
With Selection.Tables(1)
For Each oCell In .Columns(1).Cells
Set oRng = oCell.Range
oRng.End = oRng.End - 1
If DateDiff("d", oRng, Now) 365 Then
oRng.Font.Color = wdColorGreen
End If
Next oCell
End With

If the dates are each to a paragraph then select the paragraphs and run the
following macro

Dim oPara As Paragraph
Dim oRng As Range
For Each oPara In Selection.Paragraphs
Set oRng = oPara.Range
oRng.End = oRng.End - 1
If DateDiff("d", oRng, Now) 365 Then
oRng.Font.Color = wdColorGreen
End If
Next oPara

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





"Ray" wrote in message
...
I have a column of Dates, need the Macro to look at all the date in the
column and compare to the current date and if the date in the column is
more
that 365 days old want to turn the date in the column GREEN! Can this be
done? Currently there are over 500 dates in the column.

Thanks for your help
Ray



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement macro Brandon Tables 1 November 11th 09 06:17 PM
Word 2002: Macro w/today's date - update date automatically MTKathy Microsoft Word Help 1 March 13th 08 10:50 PM
If statement with a date Kathy Webster Mailmerge 5 April 24th 07 11:41 PM
which statement right , question is Choose the correct statement? how many template?when we click new doc Microsoft Word Help 1 October 16th 06 11:15 AM
which statement right , question isChoose the correct statement? how many template?when we click new doc Microsoft Word Help 1 October 15th 06 11:20 PM


All times are GMT +1. The time now is 03:58 PM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"