cdevitarun

Q: 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

Close

Q: transpose columns and rows in numbers

  • All replies
  • Helpful answers

first Previous Page 4 of 7 last Next
  • by SGIII,

    SGIII SGIII Jun 24, 2014 12:17 PM in response to Danielobix
    Level 6 (10,796 points)
    Mac OS X
    Jun 24, 2014 12:17 PM in response to Danielobix

    Glad it worked.  Thanks for the positive feedback!

     

    SG

  • by Thor Klamet2,

    Thor Klamet2 Thor Klamet2 Jun 24, 2014 12:42 PM in response to SGIII
    Level 1 (0 points)
    Jun 24, 2014 12:42 PM in response to SGIII

    just out of curiosity, any idea why the variable assignment doesn't seem to work in Numbers 2 on mountain lion?

     

    It compiled just fine and was finding the selection range and telling me what the range was (I added some display dialog lines to try to find where the error was occurring and used the name property to see if it was getting the selection and it could do "name of selection range" but not "name of my_selection" so I figured the assignment of selection range to my_selection wasn't working in Numbers 2/mountain lion. But it's an odd error since assignments should be pretty foolproof.  

     

    Not a big deal really since it works now.

     

    I'm definitely in the "child" category by the way. I used http://macosxautomation.com/applescript/iwork/numbers/range.html to give me a little bit of a clue but I don't actually know what I'm doing.

     

    Thanks again.

     

    (sorry, I'm Thor Klamet2 now, it made me create another account for some reason to use the support forum again, no idea why, same person as before though)

  • by SGIII,

    SGIII SGIII Jun 24, 2014 4:45 PM in response to Thor Klamet2
    Level 6 (10,796 points)
    Mac OS X
    Jun 24, 2014 4:45 PM in response to Thor Klamet2

    Perhaps you could post here the script that doesn't work, and I'll try to troubleshoot it with Numbers 2.  The best way to post a script now seems to be to click 'Use advanced editor' (upper right), the click the >> Syntax Highlighting > Plain.

     

    SG

  • by jotraynor,

    jotraynor jotraynor Jun 29, 2014 6:03 AM in response to SGIII
    Level 1 (0 points)
    Jun 29, 2014 6:03 AM in response to SGIII

    That is marvellous. Thanks very much for saving me hours of work

  • by SGIII,

    SGIII SGIII Jun 29, 2014 7:17 AM in response to jotraynor
    Level 6 (10,796 points)
    Mac OS X
    Jun 29, 2014 7:17 AM in response to jotraynor

    Great to hear it is helping others.  Thanks for the feedback!

     

    SG

  • by Yellowbox,

    Yellowbox Yellowbox Jun 29, 2014 8:30 AM in response to SGIII
    Level 6 (10,550 points)
    Mac OS X
    Jun 29, 2014 8:30 AM in response to SGIII

    Hi SG,

     

    Now that you are on Level 5 (Bravo! for all that work helping others) how about posting a User Tip "The easy way to AppleScript" .

     

    Regards,

    Ian.

  • by SGIII,

    SGIII SGIII Jun 29, 2014 5:25 PM in response to Yellowbox
    Level 6 (10,796 points)
    Mac OS X
    Jun 29, 2014 5:25 PM in response to Yellowbox

    Hi Ian,

     

    Ah, User Tips seem to be easily accessible again. You posted a nice one today.

     

    With the new ASC format, I still haven't figured out how to post AppleScript with proper indentation.

     

    I'm still feeling a little lost here, but glad to see the helpful leaders are still here!

     

    SG

  • by andy563,

    andy563 andy563 Sep 5, 2014 9:42 AM in response to diegoumich
    Level 1 (0 points)
    Sep 5, 2014 9:42 AM in response to diegoumich

    I got the same error the first time I tried it. I looked back at what I had copied and pasted into Automator, and found that I needed to delete the header and footer that SGIII had included: "--Transpose - select range, run, paste transposed values where wanted" & "--end of script." Once I did that, worked like a charm.

  • by andy563,

    andy563 andy563 Sep 5, 2014 11:39 AM in response to SGIII
    Level 1 (0 points)
    Sep 5, 2014 11:39 AM in response to SGIII

    Hi SGIII,

     

    Count me among the happy users of your AppleScript! Thank you!

     

    I've got another question for you, though. Perhaps this belongs in a new thread, but it seems like a logical step in this one. I am creating a data frame that I can analyze in R. However, I created a table while I was collecting my data, into which I entered two measurements of a given characteristic, then below those two measurements, I inserted an "Average" function, so that the two measurements would be averaged. The "Average" row is slightly darker, below:

    Screen Shot 2014-09-05 at 11.46.11 AM.png

    That works fine for recording data, but is not great for a dataframe, in which all of the data are arranged in columns, instead of rows. Needing to transpose the values led me to this thread, where I ran your AppleScript, which worked great.

     

    However, I am now trying to create a Template so that, in the future, when I record data in the above table, the averages will automatically be entered into the dataframe format, rather than having to be manually transposed, one row at a time. Here's a screenshot from the dataframe, of the same range of values:

     

    Screen Shot 2014-09-05 at 1.33.47 PM.png

     

    Your script works fine for values, but not for formulae. For instance, when I copy a formula location from the first table above into the dataframe, it will copy, but then dragging down the yellow circle on the lower edge of the cell to copy corresponding locations onto the cells below will not transfer row locations, only column ones. Would it be possible to write an AppleScript that would allow me to transpose the locations of a row into a column, so that the results of the averages in the above table would automatically be entered into the dataframe? It's possible to do this by typing in the address of each cell manually, but I'm working with thousands of measurements and being able to simply copy and paste via an AppleScript would make this much easier!

     

    Thanks again for your help with transposing, and thanks very much in advance for your help on this!

  • by SGIII,

    SGIII SGIII Sep 5, 2014 12:26 PM in response to andy563
    Level 6 (10,796 points)
    Mac OS X
    Sep 5, 2014 12:26 PM in response to andy563

    Do you need a "live" formula to be transposed or just the results of the formula?

     

    With recent enhancements to Numbers AppleScript support it is once again possible to transpose "live" formulas.  But that's beyond my coding skills, and you might want to post the question on the Mac OS X Technologies discussion.

     

    If it's just the result of the formula that you need in a transposed position, then the problem is much simpler and I can probably provide a solution.  Let me know.

     

    SG

  • by t quinn,

    t quinn t quinn Sep 5, 2014 5:37 PM in response to andy563
    Level 5 (5,063 points)
    Mac OS X
    Sep 5, 2014 5:37 PM in response to andy563

    Hi andy,

     

    You may not want a script at all.

     

    Take another look at Jerry's suggestion from page 1:

    Jerrold Green1

    You may need to add or subtract to your column or row functions to get things to work out. No worries about moving functions they can stay where they are.

    I have used OFFSET(base, row-offset, column-offset, rows, columns) a lot in the past where COLUMN()-x is the row-offset and ROW()-y is the column offset. INDEX seems cleaner.

     

    quinn

  • by SGIII,

    SGIII SGIII Sep 6, 2014 7:48 AM in response to andy563
    Level 6 (10,796 points)
    Mac OS X
    Sep 6, 2014 7:48 AM in response to andy563

    I am now trying to create a Template so that, in the future, when I record data in the above table, the averages will automatically be entered into the dataframe format, rather than having to be manually transposed

     

    Here is one way to do what you describe, using a formula instead of a script:

     

    Screen Shot 2014-09-06 at 10.43.28 AM.png

     

     

    The formula in D2, copied down, is:     

     

                =INDEX(TRANSPOSE(Table 1::$4:$4),ROW()−1,1)

     

    SG

  • by andy563,

    andy563 andy563 Sep 8, 2014 3:21 PM in response to SGIII
    Level 1 (0 points)
    Sep 8, 2014 3:21 PM in response to SGIII

    SG & t quinn,

     

    I've tried both of your suggestions and this is what I get, one picture showing the output (error) in the dataframe that I want the data to transfer to and the other showing the original table and selection.

     

    Screen Shot 2014-09-08 at 4.58.56 PM.png

    Screen Shot 2014-09-08 at 4.59.37 PM.png

    Is there a problem with the formula that I have entered? I can't get it to return a number in the dataframe (I'm hoping for 16.38, then 19.44 below it, then 9.185, and so on).

     

    Thanks for your help,

    andy

  • by andy563,

    andy563 andy563 Sep 8, 2014 3:25 PM in response to SGIII
    Level 1 (0 points)
    Sep 8, 2014 3:25 PM in response to SGIII

    Oh, and SG, just the values from a given cell would be fine. It doesn't need to be a formula. The output from the formula is what I'm after.

     

    Basically, my problem is that when I tell a cell the address of another, on a separate sheet, then drag down to fill a column, the address fills in as a column, rather than as a row. I need it to transpose the addresses so that the row addresses fill in on the column. I hope this makes sense...

  • by SGIII,

    SGIII SGIII Sep 8, 2014 4:31 PM in response to andy563
    Level 6 (10,796 points)
    Mac OS X
    Sep 8, 2014 4:31 PM in response to andy563

    I think the problem is that you're missing the $ anchors.  $7:$7, not 7:7. Note I have $4$4 in my example.  You can set the anchors by checking the Preserve Row after clicking the disclosure triangle in the address token.

     

    SG

first Previous Page 4 of 7 last Next