Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
Sort ignoring "The" and "A"
tks Greg ... appreciate the help!
|
#5
Posted to microsoft.public.word.tables
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Long alphabetic sort starts over w/ "A" on every new page | Microsoft Word Help |