Forumla for converting dates into days

J

Jim

I have a table in a works document. In columnn 1, I have topics, in column 2
is the date (ie August 12, 2005), column 3, is to show the day of the week
(ie Monday)

PLease help!!!!!
 
D

Doug Robbins

I don't think that Works has this capability, but with Word, the format
function can be used:

MsgBox Format(#8/12/2005#, "DDDD") returns Friday

So when you have the selection in the table, you could use a macro
containing the following code, (assuming that the first row of the table is
a heading row;

Dim mytable As Table, dtrange As Range, i As Long, strDate As Date

Set mytable = Selection.Tables(1)
With mytable
For i = 2 To .Rows.Count
Set dtrange = .Cell(i, 2).Range
dtrange.End = dtrange.End - 1
strDate = dtrange
.Cell(i, 3).Range = Format(strDate, "DDDD")
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

macropod

Hi Jim,

Simply bookmark the date (not the cell!) in column B, then use a ref field
in Column C to extract the date. For example:
If the date in B1 is August 12, 2005, and you bookmark this as 'B1Date',
then you'd use a REF field in C1 coded as:
{REF B1Date \@ dddd}. This should return 'Friday', not 'Monday' as indicated
in your post ...

Cheers
PS: The field braces (i.e. '{}') are created in pairs via Ctrl-F9.
Alternatively, you can create the REF field via Insert|Field.
 
T

trinity

Is there a way to get this added to a new row automatically when the ne
row is created (eg by pressing tab at the end of the last row)?
 
D

Doug Robbins - Word MVP

If you were using formfields as in a protected document, you could use a
modification of the following:

Sub addrow()

'

' Macro created 02/02/03 by Doug Robbins

' To add a new row to a table containing formfields in every column

' automatically on exit from the last cell in the present last row of the
table

Dim rownum As Integer, i As Integer

ActiveDocument.Unprotect

ActiveDocument.Tables(1).Rows.Add

rownum = ActiveDocument.Tables(1).Rows.Count

For i = 1 To ActiveDocument.Tables(1).Columns.Count

ActiveDocument.FormFields.Add
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
Type:=wdFieldFormTextInput

Next i

ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
1).Range.FormFields(1).Select

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True



End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top