How to split a table in InDesign? There is no simple way to split a table in InDesign!
By splitting a table, I mean dividing it into two tables. Say you have a table with 1000 rows. You want to turn that into two tables, A and B, where Table A will contain rows 1–500, and Table B will contain rows 501–1000.
Before:
After:
Why might this be useful? There are plenty of reasons. Two small tables can be more manageable than one big one. (If you’re exporting a huge table to ePub, splitting it will improve performance. In fact, if you’re planning to convert your ePub to an Amazon Kindle .kpf file, no table is allowed to have more than 20,000 characters and it becomes necessary to split a large table. Which is what prompted me to write the script, by the way.)
Or perhaps you simply want to add some text between the tables.
Microsoft Word has this feature built in. Of course. Click on “Split Table”. But not InDesign.
So I Googled “Split Table in InDesign” and couldn’t find a script I was happy with.
(I did find this on CreativePro.com, and in the comments David Blatner links to a script which probably does the job. I didn’t try the script, because I saw this in it:
app.cut(); selectRows(myNewTable, 1,1); app.paste();
There’s nothing really wrong with that code, but script purists will tell you to avoid using cut and paste. There is usually a better way of doing things. Why avoid cut and paste in a script? Well, when you invoke cut, you’re using the system clipboard. So if someone has something precious which they’ve copied to the clipboard, it will be destroyed if you use cut and paste in a script. That’s poor style. People are entitled to feel that their system clipboard should remain intact after running a random script in InDesign.
It’s probable that more googling would have come up with other scripts. But it’s more fun to do it yourself if you can!
So below you can download a free script that will split a table in InDesign. It’s called “Split Table Before” to make it easy to remember that on whatever row of the table you place your cursor when you run the script, the result will be that the table will be split before the cursor. The row the cursor is in will become the first row of the second table. (This is how it works in Word too.)
Instructions
(1) Download and install the script as usual for InDesign scripts.
(2) Place the text cursor in a cell somewhere in a table, or select a cell, or a row.
(3) Run the script.
(4) The table will be split in two. The row that has been selected will become the first row of the second table.
(If you’re not happy with the result, a single Ctrl-Z will undo the operation of the script.)
I hope you find it useful! If you find any bugs or limitations, please leave a comment below or on the Id-Extras User Forum.
Download
To download “Split Table Before”, fill in your name and address and it will be automatically emailed. By doing so you also agree to receive occasional emails from Id-Extras.com with interesting InDesign tips and tricks, news, and free scripts.
Rosieh
November 21, 2024 6:26 amThanks for your help! It worked well.
Thanks a lot!
Paul Erdman
March 16, 2024 3:37 amThank you for the script! I’ve been able to modify it to work in a much larger project I’m working on. But for my project I need to insert a hard return between tables, so that each table is in its own paragraph. Working on figuring that out now. If you have a suggestion let me know. If i figure it out I can come back here and post an answer.
Paul Erdman
March 20, 2024 7:24 pmI figured it out. I haven’t worked a lot with insertion points so I had to study up on how they work. I added these lines after the line that defines T2 as the second table. I basically get T2’s insertion point and add the hard return there.
var t2offset=t2.storyOffset;
t2offset.contents=”\r”;
Thanks again for the useful script!
Ariel
April 3, 2024 3:11 amCool!