Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sorting multiple lines of text (2003, SP1)

    I have a long text file of names and addresses, formatted with the first line as the name and the next lines as the address and the last line with the phone number. They are all the names of businesses so there's no first name/last name issue. I want to sort it by name, i.e., grouping each name and address as one block of data. Importing into a one column table would seem to be the way to do it, but how do I get each name and address into its own cell? Each block of data is four lines. Any ideas would be appreciated.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    Hi Andrew:
    There may be an easier way, but...
    If I understand correctly, you have something like:

    Banana Business
    123 Main Street
    Anywhere, ST 11111
    (800) 555-1111

    Apple Business
    456 Somewhere Ln.
    City, ST 22222
    tel no. here

    IF you have a paragraph mark between each block, try the following:
    1. Without wildcards:
    Find: ^p
    Replace All: %%%

    2. Without wildcards
    Find: %%%%%%
    Replace All: ^p
    This will replace what was originally a double paragraph with a single paragraph mark.

    3. Sort alphabetically

    4. Without wildcards
    Find: ^p
    Replace All: ^p^p

    5. Without wildcards
    Find: %%%
    Replace: ^p

    Note: Do this on a copy, as I never want to perform complex Find/Replace operations on an original without testing.

    Take a look at the solution by Klaus Linke & the thread surrounding <post#=176634>post 176634</post#> for an alternate solution.
    Hope this helps,

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    Hi Phil,

    Thanks for the idea. It worked fine, but I really would like to use a one column table, with a ^p separating each line in the address and a new field for the next name and address. The reason is that the list of names is to be used to create a directory of the businesses, and I need to be able to add new ones without having to figure out exactly where in the list they should go. Also, if any are mis-spelled, i would like to be able to correct them and just have someone re-sort the list. Any thoughts on that?

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    Addendum: I read your post too quickly the first time. The best way to do this in a table is to have one column for EACH field & a separate row for each record. You shouldn't use a one column table because that won't help you with sorting at all.

    At a minimum, I'd do this (without using wildcards):
    1. Find: ^p^p
    Replace All: %%%
    2. Find: ^p
    Replace All: ^t

    This assumes that you don't have any tabs in the document when you start.

    3. Find: %%%
    Replace All: ^p

    4. Sort by paragraph

    5. Convert to table, using tabs as the delimiter.

    Quite frankly, I'd want tabs after the City & State.
    i.e.
    <table border=1><td align=center valign=top>name</td><td align=center valign=top>address1</td><td align=center valign=top>address2</td><td align=center valign=top>city</td><td align=center valign=top>state</td><td align=center valign=top>zip</td></table>
    Cheers,

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    San Jose, California, USA
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    Actually, one-column tables sort exactly the way I want them to. If you have a multi-line cell with a carriage return at the end of the first line. the table will sort on the first line if you select "paragraphs" as the way to sort. Select the entire table, click on "Sort" in the Table menu, select "Sort by column 1" and using "paragraphs". So what I'd like to do is get my address list into a one-column table, with the name on the first line of a multi-line cell.

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    Hi Andrew:
    Well, OK. But I really think it's more versatile when you have each column a separate field. You can't use mail merge effectively with the way you're doing it. In that case, forget about Find/Replace.

    1. Create a 1 row 1 column table.
    2. Select the entire document.
    3. Copy & paste into the table.
    4. Use the Tables & Borders toolbar, select the pencil button, & draw a line between each block right over the second paragraph mark. The paragraph mark will disappear & you will have each address block in a separate cell.
    Hope this helps,

  7. #7
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Quakertown, PA, Pennsylvania, USA
    Posts
    517
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    Phil's right, of course.

    Matter of fact, here's exactly how I'd do it:

    Get the data into 4 columns.
    Click inside the table and hit Table-Select-Table.
    Copy.
    Go to Excel.
    Paste.
    Save the file.
    Use it as a data source for a mail merge that sets up your "business directory" the way you want it to appear.
    This way, you can very easily use the Excel file to maintain your data in simple and sortable columns, and update your business directory by doing a simple mail merge each time.
    When you first set up the mail merge, and BEFORE you actually perform the merge, save the mail merge main document as a template.
    Keep track of your data in the Excel file.
    Whenever you need an updated business directory, hit File-New, double-click your template, merge.

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Sorting multiple lines of text (2003, SP1)

    The easiest way to convert text to a table when you have paragraph marks is to use a peculiar character (e.g., Alt+0254) to delimit your blocks of data. Here's a macro example:
    <pre>Sub TableizeBlocksOfText()
    ' One column table, assumes rows are delimited by ^p^p
    ' Start with data selected...
    If MsgBox("Tableize this document?", vbQuestion + vbYesNo) <> vbYes _
    Then Exit Sub
    Selection.HomeKey unit:=wdStory
    With Selection.Find
    ' Set defaults
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    ' Replace ^p^p with Chr(254)
    .Text = "^p^p"
    .Replacement.Text = "

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •