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.
Terre Spencer
July 5, 2022 11:17 amHello,
This would be ever so much more useful if the space could be adjusted via a pop-up palette for inserting the amount of space between table.
Thanks,
Terre
Ariel
July 5, 2022 1:31 pmHi Terre,
The space between the tables depends on the “Space before table” setting of the 2nd table (Table > Table Options > Table Setup Tab > Space Before).
(Not sure why the “space after” setting of the 1st table doesn’t seem to make a difference.)
Ariel
Terre Spencer
July 5, 2022 2:59 pmAh, thanks! This will be very helpful! 🙂
Ariel
July 5, 2022 3:01 pmYou’re welcome. Are you also needing to split tables for ePub export?
Terre Spencer
July 5, 2022 3:03 pmNot right now, but as a freelancer, that can change next week. I just never know what is coming up next. 🙂
David Blatner
July 6, 2022 5:45 pmThanks! I put a link to here in that original post on CreativePro you pointed to.
Ariel
July 7, 2022 1:03 amGreat, thank you!
Sayed Ali Mousawi
July 7, 2022 3:08 pmThank you very much Ariel, Good job!
John
August 30, 2022 9:49 pmHello Ariel, Thank you for an excellent script. I was able to run once but then received an error.
Error Number: 46599
Error String: Cells cannot be deleted
Line 8
Ariel
August 31, 2022 2:57 pmHi John,
I’d need the ID file to be able to look into this. Can you send it to me?
Thanks,
Ariel
John
August 31, 2022 4:54 pmHello Ariel,
I sent the ID file to you for review. Thank you.
Ariel
August 31, 2022 5:49 pmThanks for the files.
I’ve updated the script. (itemByRange doesn’t seem to work in all cases, but a plain loop does.)
Download the new version from this page again. Does that fix it for you?
John
August 31, 2022 6:30 pmThe table split but odd behavior when undo is selected…it appears that the function is not working. Thank you.
Ariel
August 31, 2022 6:37 pmI think that’s fixed now. Try downloading it again.
John
August 31, 2022 6:50 pmHello Ariel,
Yes, it works as anticipated. Nice work! Thank you for your help.
Jennifer
December 28, 2022 5:46 pmI got the link to download the script, but when I click on it, I get an error message that the link is too old.
Ariel
January 6, 2023 4:59 amHi Jennifer,
Try sending yourself a link again from the form on this page. I just tested it and the links it send are working for me! Make sure the link isn’t being blocked or modified by some sort of firewall or Internet filter…
Chris
June 22, 2023 11:30 amOh man, this has been a God send – thanks a mill!
Ariel
June 22, 2023 12:51 pmThank you, Chris.