Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Bob
 
Posts: n/a
Default Sort ignoring "The" and "A"

My table is list of book titles and I wish to sort aphabetically
ignoring articles "The" and "A" so that a title such as "The Zebra" is
sorted as letter Z. Is there a function in Word to permit ignoring
articles?
TIA
Bob

  #2   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Sort ignoring "The" and "A"

Bob,

AFAIK it can't be done without some manipulation of of the table.
Basically, you would need to strip off the first word of the list if it
was an "A" or the word "The," then sort the list, and finally add the
word "A" or "The" back where appropriate. I cobbled together a macro
which does this automatically for a list of title in the first column
of a table. The testing was very limited so it may not work for you:

Sub Test()
Dim oCell As Cell
Dim i As Long
Dim j As Long
With Selection.Tables(1)
.Columns.Add BeforeColumn:=.Columns(1)
For i = 1 To .Rows.Count
If .Cell(i, 2).Range.Words(1) = "A " Or _
.Cell(i, 2).Range.Words(1) = "The " Then
.Cell(i, 1).Range.Text = .Cell(i, 2).Range.Words(1)
.Cell(i, 2).Range.Words(1).Delete
End If
Next
.Sort FieldNumber:="Column 2",
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscending
For i = 1 To .Rows.Count
j = .Cell(i, 2).Width
.Cell(i, 1).Merge MergeTo:=.Cell(i, 2)
.Cell(i, 1).Width = j
Next
.Columns(1).Select
With Selection.Find
.Text = "^13"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Sort ignoring "The" and "A"

You might also want to sort this like,

Zebra, The

Use:

Sub Test2()
Dim oCell As Cell
Dim i As Long
Dim j As Long
With Selection.Tables(1)
For i = 1 To .Rows.Count
If .Cell(i, 1).Range.Words(1) = "A " Or _
.Cell(i, 1).Range.Words(1) = "The " Then
.Cell(i, 1).Range.InsertAfter ", " & .Cell(i, 1).Range.Words(1)
.Cell(i, 1).Range.Words(1).Delete
End If
Next
.Sort FieldNumber:="Column 2",
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscending
End With
End Sub

  #4   Report Post  
Posted to microsoft.public.word.tables
Bob
 
Posts: n/a
Default Sort ignoring "The" and "A"

tks Greg ... appreciate the help!

  #5   Report Post  
Posted to microsoft.public.word.tables
Klaus Linke
 
Posts: n/a
Default Sort ignoring "The" and "A"

"Bob" wrote:
My table is list of book titles and I wish to sort aphabetically
ignoring articles "The" and "A" so that a title such as "The Zebra" is
sorted as letter Z. Is there a function in Word to permit ignoring
articles?
TIA
Bob



Hi Bob,

Another possibility is to format "The " and "A " and "An " as hidden text,
temporarily.
Hidden text is ignored in sorting, as long as it isn't visible on screen.

To achieve that, you could use wildcard replacements, say replace "The "
with "^&" and "Format Font Hidden" (or Ctrl+Shift+H) in "Replace with" .

Once sorted, you can select all the table and set the font to "Not hidden".

Greetings,
Klaus


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
Long alphabetic sort starts over w/ "A" on every new page ao Microsoft Word Help 0 December 7th 05 08:08 PM


All times are GMT +1. The time now is 07:35 AM.

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

About Us

"It's about Microsoft Word"