Macro to Sort on Time

S

SoNew2This

I work with a custom report writer that pulls data from a database onto a
report. One area of the report contains two columns with multiple rows. One
column is a time entry. The time entry can be 'out of order'.
Is there some sort of Macro that will select this table and sort the
contents on the first (time) column?
 
G

Graham Mayor

Assuming column 1, assuming the column has a header row, and assuming the
time is in a legitimate time format, the following will sort the times

With ActiveDocument.Tables(1).Columns(1)
.Sort ExcludeHeader:=True, _
SortFieldType:=wdSortFieldDate, _
SortOrder:=wdSortOrderAscending
End With

If there is no header row change the ExcludeHeader to False

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - 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