is now part of CreativePro.com!

Merging Two Tables Together in InDesign

20

Sharon wrote: Is there any way to merge two tables into a single table?

The bad news is that there is no way to merge two tables together in InDesign. The good news is that you can do it outside of InDesign! The trick? Tagged text.

[Editor’s note written ex post facto: This is a great way to learn about tagged text, but there is now a much easier solution… read about it here.]

Tagged text is an often-overlooked feature in InDesign, but it lets you do all kinds of cool things to text. You can think of tagged text as being like HTML: It’s a way to describe text formatting using codes. The best way to see what tagged text looks like is to select some text in InDesign, choose File > Export, pick InDesign Tagged Text from the Save as Type (or Format) popup menu, and save it to disk. Now open that file in a text editor, such as NotePad, TextEditor, or TextWrangler.

Virtually anything you can put in a text frame you can express with tagged text. (I say “virtually” because I haven’t tested everything and I bet there are some things — such as anchored objects? — that just won’t handle the conversion to tagged text well.) Tables are part of a text flow, and they are converted into tagged text well. So if you put two tables in a row and export them as tagged text, you can tweak the codes to merge them into a single table.

Is this for the faint of heart? No! But it’s fun to know you can do it.

First, search for the text “TableStart:”. For example, it may appear like this: “TableStart:2,4:0:0”. That means this table has two rows and four columns. Change the number of rows to the total (this table plus the second table).

Now search for “TableEnd:”. That signifies the… well, I think you can get that one. To merge the table, delete all the text from the TableEnd tag (including the angle brackets around it) and ending just before the next “RowStart” tag. (But leave the angle bracket before “RowStart”, of course!)

Finally, save your new document (I suggest saving it with a new name so you can go back to the original if you make a mistake) and import this text file into your InDesign document using File > Place. The tables should be merged! If it doesn’t work, try again. If it still doesn’t work, take a look at the sample files I put here. If it still doesn’t work after you try 3 times and you can’t figure out what you’re doing wrong, you can email me. ;) I don’t guarantee this trick; it’s clearly playing with fire, but you can cook up some great results!

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Yes, great trick

    But what about this, if the tables have the same number of columns, well if tables are simple ?

    Table 1 has 4 lines and 4 columns
    [Separated]
    Table 2 has 10 lines and 4 columns, some of the cells are even merged

    – Select the whole Table 2 by clicking in the upper left corner
    – Edit > Cut
    – Click in a cell in the last line of the table
    – Right-Clic > Insert > Row… Add 10 lines Down
    – Select these 10 lines and…
    – Edit > Paste and that’s it, even merged cells are preserved…

  • That’s a great “tinkering under the hood” solution — I love that sort of thing. And any excuse to play around with and familiarize yourself with the power of InDesign Tagged Text is worth exploring.

    But there may also be a way to “merge” two tables more simply, provided the tables themselves are fairly simple. I use quotes because it’s not really a true merge function, but it will put all the data into one table.

    Let’s say you have a table of three rows and four columns (the source table) that you want to include in a table with any number of rows, but also with four columns (the destination table). First, add three rows to the destination table, then select the three rows from the source table by either dragging through all the cells in all three rows or selecting all three rows when you get the InDesign arrow cursor that selects whole rows or columns. Cut or copy those rows, then select the three empty rows you created in the destination table and paste in the rows from the source table.

    Again…this is a simple method for simple tables. And it will work with columns, too…but first you need to create (insert) the “placeholder” rows/columns you need so that what you copy from the source table has somewhere to go in the destination table. Many things could trip you up on this — such as the presence of merged cells in either the source or destination table — but if your two tables aren’t too complex, it does work.

    You can also paste an entire table into one cell of another table if, for example, you wanted to avoid creating a complex series of merged cells in an otherwise simple table. But the individual cells of that “nested” table then have to be selected, edited and formatted independently of table into which it’s been pasted.

  • I need to learn to write less and click “Submit Comment” faster. Branislav beat me to it. :)

  • I tip my hat to Branislav and Michael. I was so proud of my complicated solution that I forgot even to try the simple solution! As Branislav noted, copying and pasting rows (or columns) works even for merged cells.

    It appears to work for split cells, too, but note that a horizontally split cell adds an additional row. That is, if you split a cell horizontally, then try to select that one row, you actually have to select two rows! I hadn’t noticed that before.

    So chalk this table-merging exercise up to a good excuse to discuss (and play with) tagged text. Oh well.

    Next week: How to type characters into InDesign by toggling binary code in with dip switches. ;)

  • asarya says:

    The copy paste is the obvious solution, but seems to trip up when things like embedded tables are inside the cells to be pasted.
    And pasting cells doesn’t seem to keep all the attributes – it’s a little hit and miss.
    So the tagged text was a good experiment for me, even if recreating and reformatting the cells might have been quicker in the end :)

  • Liam says:

    Thank you. Now that I’m up to CS3, I know I should have known this trick by now, but reading this has been a great help!

  • ej says:

    What about a simpler solution for merging hundreds of tables? I’m using Data Merge to create a table of items from an excel sheet (with some complicated formatting) and I can create a table of one row for each record, but merging those tables has proved… troubling.

  • ahamed meeran says:

    hi
    This is ahamed, i need some indesign ideas…i am using indesign CS3..
    i have ms access file contain 7 columns.
    1st column company name
    2nd column postbox
    3rd column city
    4th column tel
    5th column fax
    6th column email
    7th column web address

    just i convert xml from ms access file. then i import to indesign it showing 7 lines per data.

    my requirement for indesign
    first line: company name
    second line: postbox, city, telephone and fax
    third line : email
    fourth line: website

    already i create tag for all. but how to two tag in one line

    so please give me any ideas for this topic.

    thanks

    ahamed

  • @Ahmed: This is another good example of when XML is probably more complicated and difficult than you need. What you are describing is a great use for Data Merge. Do a search on this site for data merge, and you’ll find many good resources. However, you will need to export csv or tab-delimited text from Access.

  • Howard Latimer says:

    Hi – the original solution described above worked perfectly. One thing within ID CS3 still perplexes me as it relates to this problem:
    1. I originally inserted a forced break at the end of a row.
    2. The table text was later modified, so I need to remove the break.
    3. I chose Table>Cell Options>Rows and Columns and then chose “Start Row Anywhere”
    4. The break was removed but I still ended up with two distinct tables (it was originally one table until the force break) – you’d think the logic would be to combine the tables back into one, no?

    Anybody have any thoughts or did I do something wrong?

  • @Howard: I don’t think using the break option (in Keep Options) will actually break the table into two tables. It’s probably still one table. If the table is still breaking from one frame to the next then there’s some other reason it’s doing that.

  • Howard Latimer says:

    Trying to describe this a little better: The table is no longer breaking into 2 frames but instead is being treated as two tables in one frame (this is after I chose “Start Row Anywhere”).

    I could not replicate this using a basic table, no text in a new document. So perhaps I did do something else…I’ll fool around a little bit and drop a note if I ever figure it out. Thanks!

  • Howard Latimer says:

    fm previous string, David Blatner wrote “If the table is still breaking from one frame to the next then there?s some other reason it?s doing that.”

    I can’t duplicate the original issue, so I’ll chalk it up to my own operator error…

    Thanks for the help, though, as well as the Tagged Text tip!

  • In-Tools also has a free script that will merge two tables together: https://in-tools.com/products/scripts/

  • Tadas says:

    If you’re copying your table from Word into InDesign and want to merge them, just create additional rows in the first table in InDesign, then copy data form Word needed to be pasted ino empty cells in InDesign, make sure you copy only text (Edit, Preferences, Clipboard handling, then just select Text Only option) in order to not paste table in table. Now just paste your text and it will fill all your remaining cells. Simple.

  • Dan Williams says:

    Hi Guys,

    I have an extension to Branislav and Michael’s method.
    Let’s say you have a large data set, three A4 pages each with their own separate full page table.
    To combine these into one table AND link them across the three existing text frames I do the following (bear with me):

    1. Go to Window > Type & Tables > Table
    2. Select the entire table in the second text frame (by clicking in the top left). Note the total number of rows in the Table panel. Then Edit > Copy/Cut
    3. Select the last row of the table in the first text frame. Right click > Insert > Row. Enter the number of rows you previously noted and click ‘Below’.

    *Here’s the trick*

    4. All the newly created rows are now selected (even if they are outside the text frame) including the initially selected row. Hold (mac) Option + Control + Shift and select the first row of the NEW BLANK ROWS you just created. You should now only have the new cells selected (even if you can’t see them all).
    5. Cmd+V (paste) and it’s all there, where you want it.
    6.Now you can link it with the text frame you just cut/copied from by entering that text frame and clearing it/deleting the table from it.
    7. Click the link button in the first text frame and then click the second text frame border. The content should automatically spill over to the second frame.
    8. Repeat steps 2-7 with the third text frame, adding the new rows to the bottom of the table data (now in frame two).

    I’ve written it a little detailed but it’s simple and makes sense once you run through it.

  • GIlbert Salcedo says:

    Hi Guys,

    I think this is nice to use if you have simple tables need to merge how about if you have complicated table that compose of various style and merge some table.

  • Mariyum Imaran says:

    What happens if you merge two cells in a table row in indesign ??

  • Aneliya Krasteva says:

    Actually there is a way to merge two tables together in Indesign
    1. Select one of the tables, press Ctrl X to cut it
    2. Select the other table.
    3.Go to -Table menu
    4. Click -Paste before or Paste after depending on where you’d like to add it.
    Now the two tables are merged and act like one common table.

    • David Blatner says:

      Thank you, Aneliya! Ah, that is one of the challenges of running a site with articles going back 15+ years. You are right that there is a much easier way now. I have updated the article above.

  • >
    Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo