Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Alphabetize Data in Tables

Christopher wrote:

Do you know how to sort data in a table? From time to time, we need to change around the data in our tables. I always end up manually re-alphabetizing. But I wish I could find a way to sort it like you can in Excel.

Pariah Burke wrote a really good article in the last issue of InDesign Magazine in which he talked about this very thing. I would encourage you to get that article and read it through. But the quick answer is: There’s really no good way to do this, but there are two mediocre ways.

SortParagraphs

There’s a script called SortParagraphs that comes with InDesign CS3 (in CS2, it’s on the installation discs). This is a great script for sorting or alphabetizing paragraphs. Unfortunately, it doesn’t work for tables. So, you would need to convert that data from a table to text by selecting the table with the Type tool and choosing Table > Convert Table to Text. Then select the text, run the script (double-click on it), select the text again, and convert it back to a table (Table > Convert Text to Table).

If you don’t want to convert the whole table to text, you could select the rows you do want to sort, copy them, paste them elsewhere, convert-sort-convert, and copy the data back. (Copying and pasting data like this is available only in CS3. If you have CS2, you’d need the PopTbFmClip script from Dave Saunders.)

I’m hoping that in a future version, Adobe will update the script so that it works on table data, too.

Use Excel

If you don’t want to use that script for some reason, you can use Excel’s sort feature (which is definitely superior and more flexible). In this case, you would select the table rows you want to sort in InDesign, copy them to the clipboard, paste them into Excel (or Numbers, or whatever spreadsheet program you’re using), sort them, then copy-and-paste them back.

As we’ve noted earlier, the ability to paste data back into table cells is new in CS3, and the trick is you need to select the cells themselves (make sure at least one cell is selected… not just have a flashing cursor inside the cell).

If anyone can offer a better solution to alphabetizing tabular data, I’d love to hear it!

Related Articles
Comments

13 Comments on “Alphabetize Data in Tables

  1. I always copy the data and create a new table and convert that to text, as said above. But in CS3 once the cells and rows are the same count as the tabs you can simply copy the text that is tabbed in the document back into the table, it will go into the correct row and column.

    So there is no need to create a new table for this, just simply copy your tabbed text back into your table.

    I know it’s not much different than what was said already, but it’s a little different and it’s good to know that you can copy tabbed text right into a table, providing the tabs match the table layout.

  2. Great! I didn’t know that SmartStyles did that now, and I thought I remembered seeing Peter’s script, but I couldn’t find it. Thank you for the links!

  3. Wanted to point out that, on the Mac side at least, there is a clipboard enhancement called CopyPaste that provides a “Sort” command, context-menu accessible. However it handles the clipboard, it manages to actually sort an entire table in place, your choice of ascending or descending. Very nice; I’ve been using it to sort my tables for quite a while now.

  4. You can link Excel or Word and Indesign files (go on “edit”, preferences, type, links). So after you edit something (like sorting, deleting, inserting etc.) in linked excel file, you click on “update link” in the palette “links”. You will lose some of formating in Indesign, but you can bring it easily back by applying previously created styles.

  5. I learned two things regarding this. First, to access the Scripts, go to Window ==> Utilities ==> Scripts.
    Second, if you are going to use the script mentioned to sort and you convert the table to text, make sure that before you do that you do not have paragraph marks within your cells! If you have paragraph marks, the script does not know that you had the lines that are separated by paragraph marks in the same cell in your table.

  6. I am using Peter’s script in ID CS4. However, our tables have one column that has images in it, and when I use the sort feature, the images disappear. Does anyone know a solution to this? Does the Woodwing software allow table sorting with images? Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>