Table sorting

S

Sasa

Is there some VBA function that will sort by A-Z Table
with, for example 20 rows (each row containing some text),
i.e. first row will be text begining on A, second on B etc.
Is this possible?

Help appreciated.
Regards.

Sasa
 
P

Peter Hewett

Hi Sasa

The easy way to do this is to create the table you want to sort and populate
with some test data. Position the cursor somwhere in the table. Now record a
new macro and then select Table/Sort, and specify how you want your table
sorted. Turn of the macro recorder and you've got a macro to sort your table.
The code it generates will look something like this:

Selection.Sort ExcludeHeader:=False, FieldNumber:="Column 1", _
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscending, FieldNumber2:="", _
SortFieldType2:=wdSortFieldAlphanumeric, _
SortOrder2:= wdSortOrderAscending, FieldNumber3:="", _
SortFieldType3:= wdSortFieldAlphanumeric, _
SortOrder3:=wdSortOrderAscending, Separator:= wdSortSeparateByTabs, _
SortColumn:=False, CaseSensitive:=False, LanguageID _
:=wdEnglishNewZealand


HTH + Cheers - Peter
 

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