![]() |
#1
|
|||
|
|||
![]() Hi all I am trying to sort a number of catalog entries, and have been helped immensely by this thread (https://www.msofficeforums.com/word/...rd-2007-a.html) on sorting paragraphs, but I've run into a confounding problem. I have a series of catalog entries that I am trying to sort. Some have "subject" headers in brackets and others simply are headed with the author, as below. HTML Code:
zxc. Marie, A., Dr. Pellagra ... zxc. [Carver, George Washington.] Merritt, Raleigh H. From captivity to fame: zxc. [Methodists.] Anderson, James A. Centennial history of ... HTML Code:
Carver, George Washington.] Merritt, Raleigh H. From captivity to fame: Methodists.] Anderson, James A. Centennial history of ... Marie, A., Dr. Pellagra ... Here is the macro I have. My programming skill is limited, so apologies for what may be messy code. I've been find/replacing the hidden text outside of the macro so far. HTML Code:
Sub Sorttest() ' Application.ScreenUpdating = False Dim Tbl As Table With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindContinue .Format = False .MatchWildcards = True .Text = "^13^13" .Replacement.Text = "|" .Execute Replace:=wdReplaceAll .Text = "^13" .Replacement.Text = "~" .Execute Replace:=wdReplaceAll End With Set Tbl = .ConvertToTable(Separator:="|", NumColumns:=1) With Tbl .Sort ExcludeHeader:=False, FieldNumber:="Column 1", CaseSensitive:=False, _ SortFieldType:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending .Rows.ConvertToText Separator:=wdSeparateByParagraphs End With With .Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindContinue .Format = False .MatchWildcards = True .Text = "~" .Replacement.Text = "^13" .Execute Replace:=wdReplaceAll End With End With End Sub |
Tags |
hidden text, macros, sort text |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tectonicseer | Excel Programming | 1 | 07-27-2014 11:54 AM |
![]() |
Ulodesk | Word VBA | 2 | 06-19-2013 08:46 AM |
![]() |
zulhfreelancer | Excel | 1 | 06-14-2013 04:12 PM |
![]() |
christie | Word | 1 | 08-17-2011 09:10 AM |
CAUTION!! Sorting a spreadsheet with hidden columns will trash your data. | psmaster@earthlink.net | Excel | 0 | 11-24-2009 11:54 AM |