Joining Tables
Steve wrote,
I have a (hopefully) quick question about InDesign CS3 tables. If I have two tables (think about a print book -one table on each facing page of a spread); is there any easy way to combine those into one table instead of two? I’m repurposing the content and really need the table to be one very wide table. I could always write an AppleScript to do it, but if there was some way you knew about already, it would save me some time and brain-pain.
Unfortunately, there is no Join Tables command in InDesign, but it’s not too hard to do manually. There are two key steps: First, prep the “receiving table” with enough empty rows and columns to hold the contents of the table data you’ll be adding to it. The second key is to be sure and select the entire cell of where you want the new data to begin before you paste.
If you’re familiar with tables, that should be enough, otherwise, follow these step-by-steps.
Let’s say these are your two tables (we’ll call them Table A and Table B):
To join Table B to the right of Table A, first count the number of columns in Table B. If there are a lot of columns, don’t bother counting them by eye. Just click inside the table with your type cursor and look at what the Number of Columns field reports at the top of the Table panel (Window > Type & Tables > Table). Here we can see that there are 6 columns.
Next, add that number of columns to the first table. A fast way to do this is to click anywhere inside Table A and enter “+ [number]” to the Number of Columns field (which now shows the number of columns in Table A) in the Table panel. In this example, the field showed 5, and I added “+6”. When you press Return/Enter, InDesign does the math and adds columns to the right of Table A, regardless of which cell your cursor was in.
If there are more rows in Table B than Table A, do the same for the Number of Rows field for Table A.
Alternatively, right-click inside the last cell (last row, last column) in Table A, and add extra columns and rows with the Insert commands from the contextual menu. Make sure that “Right” radio button is selected when you add columns, and Below when you add rows.
In this example, I just need to add extra columns:
Now select all of Table B with your Type cursor (I like to right-click inside it and choose Select > Table) and then copy or cut it to the clipboard.
Finally, select the first cell (top of the first empty column) you added to Table A by clicking inside it and pressing the Esc key. This tells InDesign where to start pasting the table cell content in your clipboard.
Paste in your table, and et voila, one table:
Troubleshooting
If nothing happens when you paste in your table, there are not enough rows/columns starting with your “Start Here” cell selection to hold all the cells in the clipboard. You need to add some. It’s okay if there are too many, not okay if there are not enough.
If the entire table gets pasted into a single cell, you probably forgot the “select the entire cell” step, and just had your cursor blinking in the starting cell. Undo, select the cell itself (press the Esc key) and try again.
Even Faster
If you convert Table B to tabbed text (Table > Convert Table to Text), you don’t need to add more than one empty row or column to Table A. Just copy the tabbed text to the clipboard, add an empty row or column to Table A (depending if you want the data to be appended to the bottom or to the right of Table A), select the starting cell as above, and paste. InDesign adds enough columns and rows as necessary to hold the data, magically reconverting the tabbed text into cell content.
Not to forget Davids way:
https://creativepro.com/merging-two-tables-together-in-indesign.php
:)
Great post Anne-Marie – the joining of tables isn’t as obvious as you’d expect. I’ve heard of people copying both tables to excel and then back to indesign, but not sure if that works, just something I heard.
Be careful not to put the table in a cell, because you can copy the whole table in a cell and it behaves strange when in a cell – like it spans across cells without wrapping the text as you’d expect.
Just something to watch for.
Thanks Eugene, yes, I saw that one there. It’s almost to the point where we can’t write anything that hasn’t been written already …. LOL. (I was halfway through a post about breaking URLs with the discretionary line break until I thought to run a search and found 2 or 3 other posts here about almost the exact same thing!)
David’s post was great, as are the comments to that post. But at least my article above provides some new information and those always-handy screen shots. ;-)
Yeh this site is a very comprehensive database that you guys have built up here. It’s certainly the best resource and it’s great that old topics resurface; and the screen shots are most helpful too :)
The fact I remembered Davids post from way back then shows I’ve been reading this blog far too long :) Long may it last.
(sorry I only know the smiley code)
Excellent article, Anne-Marie. I linked to it in a comment in this Help topic:
https://help.adobe.com/en_US/InDesign/6.0/WSa285fff53dea4f8617383751001ea8cb3f-6fe2a.html
Great article.
I can’t believe no one has written a script yet to merge tables. It’s an easy script to write and, oh so useful!
Here’s a simple script which does just that. You select two tables and run the script. You can select to merge horizontally or vertically.
Enjoy! :)
Harbs, great, you are so kind! I just tried it with my samples above and it worked perfectly.
I also tried it with two tables in the same frame separated by some text. I selected all w/the Type tool and chose Merge Below and it merged the two tables and put the paragraph text below the merge. Great!
Does your script work with CS2 and CS3?
Good work Harbs!
Does your script work with CS2 and CS3?
I didn’t test it, but it should. The one nicety which is CS4 only, is that the script is undo-able in one step in CS4.
Thanks Harbs, made some clients very happy
(well, maybe they are a bit lazy in not willing to copy/paste ;-) )
Merge Table Script!!! Thank you, thank you :)
The procedure works for combining tables by adding columns.
Is there a way to combine table A and B by adding the rows from Table B to the end of Table A?
Hi,
Can’t get this script to work, because I cannot select two tables with the text tool, even if i hold down the shift key (inDesign CS5 on a mac).
I’ve tried putting the tables in separate text frames and also putting the tables in in one text frame. But if I click on one table then shift click (and every other key combination has been tried), the first table gets deselected. If I Commond-A to select all, I just get the paragraphs not the tables themselves.
Please help, this would be really useful.
Thanks it worked and helped a lot with this issue, though it messed up some random cross-references in the tables I was working with
Anne,
Great job!. It is working for me too.