From the course: InDesign Secrets

232 Swapping column and row information in tables - InDesign Tutorial

From the course: InDesign Secrets

232 Swapping column and row information in tables

- [Voiceover] Sometimes you have a table in InDesign in which you want to swap, or switch, the columns and rows. For example, I might want all the information in this first row to become part of the first column, and the second row should be the second column, and so on. Now, there's no obvious way to do this in InDesign, but you can do it with a little trick, in fact, three tricks. You could use Excel, you could use a free script, or you could use an excellent plugin. I'll show you all three, but first, let me show you how you can do it in Excel. Now, the Excel trick works best when your table is relatively simple and you don't have any formatting, like this one. To get the data into Excel, we first need to select all the cells in the table. I can do that by simply placing my text cursor inside any one of the cells, and then pressing cmd + opt + a on the Mac, or ctrl + alt + a on Windows. That selects all the cells. Then, I'll copy all that data to the clipboard by pressing Command + C on the Mac, or Control + C on Windows. Now, I'll switch to Excel, and you can see I have a blank worksheet open here. All I need to do is paste, Command + V or Control + V on Windows. You can see all that data shows up inside the Excel document. OK, so there's the data, looking pretty much the same as it did in InDesign, except it's not formatted. I now need to deselect these cells, and then select them again and copy them to the clipboard one more time. Yes, you really do need to select and copy all those cells again in order to take advantage of a special Excel feature, which you can find in the Edit menu. First, I'll select any other cell down here, then I'll go to the Edit menu, and I'll choose Paste Special. The Paste Special dialog box gives me all kinds of options, but all I need to do here is turn on the Transpose check box, and click OK. The data is pasted back into this worksheet, and you can see that it's now transposed. What was a column is now a row, and vice versa. Now I can copy those cells one last time, head back to InDesign, but before I paste, I need to pay attention to something. This table, the original table, had four columns and five rows. However, my new table is going to have just the opposite. Before I paste, I want to make sure my table has the right number of columns and rows. I can change that up here in the control panel. I'll change this to four rows instead of five, and InDesign warns me that it's going to delete some of the data, that's OK, and I'm going to add one column. There we go. I now have the right number of rows and columns, so now I can paste with Command + V or Control + V on Windows. There you go. All the data is put back in the table, but in the new order. Oh, actually, I should point out two reasons why this might not work for you. For some people, when they paste, the whole table ends up sitting inside the first cell of the InDesign table. If that happens to you, then you might not have had all the cells selected when you pasted, or you might need to make a small change to your preferences. I'll open my Preferences dialog box by going to the InDesign menu on the Mac, or the Edit menu on Windows, and then choosing Preferences. Inside the Preferences sub-menu, I'm going to choose Clipboard Handling. Inside the Clipboard Handling pane of the Preferences dialog box, I want to make sure that this When Pasting Text and Tables from Other Applications section is set to Text Only. If I choose All Information, then sometimes, those pasted tables don't come in correctly. When I'm pasting tables, I want to choose Text Only. I'll just cancel out of this dialog box, because in this case, it worked just fine, As I said, this technique using Excel works pretty well when you have a simple table, but I'll scroll down just a little bit here, and you can see I have a little bit more complicated table here. It's formatted, it has more rows, and so on. This is where the second solution comes in. When I was researching this problem of transposing rows and columns, I discovered an old script from way back in 2006, written by Iain Anderson. You can find this script on his blog, called funwithstuff.com, and amazingly, this old script seems to work just as well today in InDesign CC as it did back then. Now, we've covered how to download and install scripts in another InDesign Secrets movie, here in the online training library, so I'm not going to cover that here. I've already downloaded and installed this one, and you can see it back here in InDesign, inside my Scripts panel, which I can find by going to the Window menu, choosing Utilities, and then choosing Scripts. There it is; Table Transpose. Now, I should point out that when you run this script, you need to select not the table, but the text frame that contains the table. I'll choose the Selection tool, the black arrow Selection tool, select this text frame here, and then run the script by double-clicking on it. Boom! In just a few seconds, the rows and columns are all switched. I love that!. The last method that I want to point out is the Active Tables plugin, and you can find that on the DTP Tools site at dtptools.com. This plugin is a commercial tool, that is, you do have to pay extra for it, but it has a wide array of cool table features, not just transposing tables, but far more, like doing table calculations. It can actually do the math inside your tables. Now, I'm not going to demo this plugin, but if you do a lot with tables, you should definitely check it out to see if it would save you time. Lastly, I do want to point out that if your table is complicated, particularly if it has merged or split cells, then all bets are off with any of these techniques. There's really no good way to transpose those, but, for a simple table that needs flipping, any of these techniques should do the trick.

Contents