You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

transpose columns and rows in numbers

I need to transpose columns and rows in Numbers and I do not want to write script to do it. Is there an easier way?

MacBook Pro, iOS 6.1.4, iWork - Numbers

Posted on Jul 29, 2013 11:10 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 29, 2013 12:51 PM

CD,


There is a TRANSPOSE function, but it's not too useful in my experience, since you have to use INDEX to read the result out of internal memory. Below are two examples, the first using TRANSPOSE and INDEX and the second using only INDEX, but this time reading the input table directly rather than via the transpose function. Note that skipping the transpose function requires that you reverse the Row and Column arguments.


In case the graphic is difficult to read, the first expression is:


=INDEX(TRANSPOSE(INDIRECT("Input")), ROW(), COLUMN())


and the second expression is:


=INDEX(Input, COLUMN(), ROW()).


Jerry

User uploaded file

97 replies

Feb 2, 2014 1:45 PM in response to SGIII

"being (apparently) the only living person on the planet with my particular combination of just four common English syllables"


That's nothing; you should try carrying around the name of a suburb of London, and one that has the unenviable reputation of being the most racist... 😉


http://www.independent.co.uk/news/uk/crime/two-decades-have-passed-but-the-hate- goes-on-in-eltham-6285108.html

Mar 6, 2014 7:29 AM in response to hplovejet

Hi Tom,


Nice to see the demo of what I call the 'Copy Transpose' script in action! You may have noticed you can share it as a "self-installing" service by choosing the .workflow package in Finder, right-clicking, and and choosing Compress.... The recipient just has to double-click the .zip package and it will move itself to the Library > Services folder so that it appears in the Services menu. (The recipient may have to click 'download anyway' in System Preferences > Privacy & Security).


SG

Mar 7, 2014 2:23 AM in response to SGIII

Awesome 🙂 I wish I knew others who share this problem so I could send this to them, but assume the Numbers "community" would be delighted to be able to simply download such a service. I assume this forum doesn't permit hosting such files, but I would be happy to do so unless anyone can suggest a better alternative.


I think I forgot to thank you for sharing this, so thanks very much!

Tom

Apr 18, 2014 9:57 AM in response to diegoumich

One other thought. If you're using Numbers 2 and not Numbers 3, then the script should work if you replace this line:


tellapplication "Numbers" totellfrontdocumenttotellactive sheet


With this:


tell application "Numbers" to tell front document to tell (first sheet whose every table's selection range's class contains range)


SG

May 20, 2014 11:27 AM in response to SGIII

Hi SGIII,


I think I'm missing something on this. I'm using Numbers 3.2 but everytime I select a range and then select the workflow I get an error message saying:


"Select a range first and then try again"


Is there something special I need to do when selecting a range ?


Hope you can help


Thanks in advance


Natalie

May 20, 2014 12:04 PM in response to Community User

Ok I solved it, well it's working now anyway !!


For some bizarre reason after I had quit numbers and re-opened the same file it is all now working, so thank you again SGIII your workflow has saved me from lots of tedious data entry.


Thanks

May 20, 2014 1:02 PM in response to Community User

Hi Natalie,


Great to hear it's working now! One thing that's easy to forget is that only one version of Numbers should be open at the time you run the script. Also some utility-type applications that jazz up your clipboard (CopyClip, Command-C, CommandClip, and probably dozens or hundreds of others) can get in the way.


SG

Jun 23, 2014 4:36 PM in response to SGIII

Your fix for getting it to work in Numbers 2 didn't quite work. Here's the version that worked in Numbers 2:


--Transpose - select range, run, paste transposed values where wanted

try

tell application "Numbers" to tell front document to tell (first sheet whose every table's selection range's class contains range)

set selected_table to first table whose class of selection range is range

tell selected_table

set first_col to the address of the first column of the selection range

set last_col to address of last column of the selection range

set first_row to address of first row of the selection range

set last_row to address of last row of the selection range

set str to ""

repeat with i from first_col to last_col

repeat with j from first_row to last_row

set str to str & (value of cell j of column i of selected_table) & tab

end repeat

set str to str & return -- add line return after row

end repeat

end tell

end tell

set the clipboard to str

on error

display dialog "Select a range first and then try again"

end try

--end script


It didn't seem to like assigning the variable my_selection to be the "selection range." Maybe it has to be declared in some way. I just dispensed with the assignment and it worked. Thanks, this will save some time in creating a mailing list using Numbers.


"She who knows not and knows not that she knows not is a fool, spurn her. She who knows not and knows that she knows not is a child, teach her. She who knows and knows not that she knows is asleep, wake her. She who knows and knows that she knows is a fanatic, kill her." -- ancient proverb

transpose columns and rows in numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.