Hi John,
I think you have to use the selection object rather than the column object.
The following works on my machine:
Dim oRng As Range
Dim iCol As Integer
Dim iStart As Integer
Dim iEnd As Integer
Dim oTbl As Table
''' set a reference to the current selection
Set oRng = Selection.Range
''' set a reference to the current table
Set oTbl = Selection.Tables(1)
With Selection
''' get the index number of the first selected column
iStart = .Information(wdStartOfRangeColumnNumber)
''' get the index number of the last selected column
iEnd = .Information(wdEndOfRangeColumnNumber)
End With
For iCol = iStart To iEnd
''' individually select each column in the original selection
oTbl.Columns(iCol).Select
''' sort each column individually
Selection.Sort SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
SortColumn:=True
Next iCol
''' reselect the original selection
oRng.Select
HTH,
Dave
> Hi there,
>
[quoted text clipped - 20 lines]
>
> John
John - 08 Aug 2005 14:09 GMT
Perfect. Thanks very much Dave.
One other question that's related to this, is, is there a way for blank
cells to be either left out altogether or chucked to the bottom of the
sorted list? I suppose thinking about it that I could continue with a
delete (shift up) blank cells at the end for each column, but are you aware
of a flag that would do this automatically?
In any case, thanks again for your help.
Best regards
John
> Hi John,
>
[quoted text clipped - 59 lines]
>>
>> John