Using Applescript to Copy a Table Across Sheets

Hi,
I am learning to use Applescript and I am not sure how to do the following:
Copy a cell value from one table in one sheet to another table in another sheet.
I tried the following:
tell sheet “B”
set value of cell 1 of row 1 of table “X” to (value of cell 1 of row 1 of table “X” of sheet “A”)
end tell
But that does not work.

I forgot to write that you must ALWAYS coerce values to strings.
set value of cell 1 of row 1 of table “X” of sheet “B” to (value of cell 1 of row 1 of table “X” of sheet “A”) as text
or
set a_val to value of cell 1 of row 1 of table “X” of sheet “A”
if class of a_val is date then set a_val to a_val - (time to GMT)
set value of cell 1 of row 1 of table “X” of sheet “B” to a_val as text
or
tell sheet "A" to tell table "X"
set a_val to value of cell 1 of row 1
end tell
tell sheet "B" to tell table "X"
if class of a_val is date then set a_val to a_val - (time to GMT)
set value of cell 1 of row 1 to a_val as text
end tell
It's necessary for :
(1) decimal numbers because an Applescript's decimal number use always the period character as decimal separator. Coercing to string replace this standard character by the localized one which is the comma in several countries.
(2) Numbers doesn't know the object date_time of Ap^pleScript. This is why you got the error : "Numbers got an error: AppleEvent handler failed.”
Coercing the date to string (or text which is exactly the same task), you send to Numbers a known structure. As you saw, in the 2nd and 3rd pieces of code, I substract the value (time to GMT) when a value is a date_time one. It's required to take care of the Numbers internal behavior.
Yvan KOENIG (VALLAURIS, France) mercredi 30 mars 2011 20:29:40

Similar Messages

  • How can I use Applescript to copy a file's icon to the clipboard?

    Hello,
    How can I use Applescript to copy a file's icon to the clipboard?
    Thanks.
    Lennox

    there is no way to do that that I know of. but you can extract an icon of a file to another file using command line tool [osxutils|http://sourceforge.net/projects/osxutils]. you can then call the relevant command from apple script using "do shell script".

  • Using Provide-endprovide copy internal table

    Hi,
    I have problem that is if i want to copy the data from infotype to internal table means
    Provide * from p9012 between  pn-begda  and  pn-endda.
    if p9012-zz_client_c EQ itemp-z_client_c.
    MOVE: p9012-begda TO it9012-begda,
               p9012-zz_dept_c TO it9012-z_dept_c,
               SORT IT9012 BY z_dept_c.
               append it9012.
    endif.
    endprovide.
    this one not copying data from infotype to internaltable.
    what i can do?
    Thanks,
    Regards,
    Nandha

    HI Use this code example..
    plz reward poins if it helps you..
    & Report  ZSAPHR_PNP
    Report ZSAPHR_PNP.
    TABLES : PERNR.
    *Infotype Declaration
    INFOTYPES: 0002, "PERSONAL DATA
               0006, "ADDRESS
               0008, "
               0000, "
               0001. "ACTIONS
    DATA : BEGIN OF ITAB  OCCURS 10,  "INTERNAL TABLE DECLARATION
           NACHN  LIKE  P0002-NACHN,
           VORNA  LIKE  P0002-VORNA,
           GESCH  LIKE  P0002-GESCH,
           GBDAT  LIKE  P0002-GBDAT,
           FAMST  LIKE  P0002-FAMST,
           HSNMR  LIKE  P0006-HSNMR,
           STRAS  LIKE  P0006-STRAS,
           LOCAT  LIKE  P0006-LOCAT,
           PSTLZ  LIKE  P0006-PSTLZ,
           LAND1  LIKE  P0006-LAND1,
           PLANS  LIKE  P0001-PLANS,
           ORGEH  LIKE  P0001-ORGEH,
           BET01  LIKE  P0008-BET01,
           WAERS  LIKE  P0008-WAERS,
           PERNR  LIKE  P0000-PERNR,
           END OF ITAB.
    DATA: G_REPID LIKE SY-REPID."Report name
    INITIALIZATION.
      G_REPID = SY-REPID.
      PNPTIMED = 'D'.
    **********************************************START OF
    SELECTION*****************************************
    START-OF-SELECTION.
    GET PERNR.
      PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
        ITAB-PERNR = P0000-PERNR.
        ITAB-NACHN = P0002-NACHN.
        ITAB-VORNA = P0002-VORNA.
        IF P0002-FAMST = '0'.
          ITAB-FAMST = 'S'.
        ELSE.
          ITAB-FAMST = 'M'.
        ENDIF.
        ITAB-FAMST = P0002-FAMST.
        IF P0002-GESCH = '1'.
          ITAB-GESCH = 'M'.
        ELSE.
          ITAB-GESCH = 'F'.
        ENDIF.
        ITAB-GBDAT = P0002-GBDAT.
        ITAB-HSNMR = P0006-HSNMR.
        ITAB-STRAS = P0006-STRAS.
        ITAB-LOCAT = P0006-LOCAT.
        ITAB-PSTLZ = P0006-PSTLZ.
        ITAB-LAND1 = P0006-LAND1.
        ITAB-ORGEH = P0001-ORGEH.
        ITAB-PLANS = P0001-PLANS.
        ITAB-BET01 = P0008-BET01.
        ITAB-WAERS = P0008-WAERS.
        APPEND ITAB.
      ENDPROVIDE.
    END-OF-SELECTION.

  • Using Applescripts w/ Mail

    In entourage - I had a menu item called scripts - that showed applescripts in a folder in the drive - i could choose one and it would perform the script on the frontmost email (and more stuff too)
    Q: is there a way to set up this menu system in apple mail?
    BTW: if there is a better way - please let me know... (I know i can attach AS's to rules....)
    Example AS: use applescript to copy email (with field names and my formatting) to clipboard - to paste different places... that type of thing...

    Also, see http://www.lists.apple.com/archives/applescript-users/ and join that list for all things AppleScript. Finally, there's an AppleScript forum under OS X Technologies.

  • How do I copy/duplicate a photoshop layer from one document to another document using AppleScript?

    Most likely I don't have the syntax correct. My task is to copy a layer in an existing Photoshop CC document (with a button, for example) to a new photoshop document. Just a simple working example should get me going on the right track. Do I use "duplicate" or copy? Thank you.

    Thank you so much for your reply Peter
    I have no idea what those brackets meant, I've followed your recommendation and my problem is fixed now.
    Kind regards
    Mariano

  • How to update popup (drop down) cells in Numbers using Applescript

    I understand that the list popups (dropdown lists in cells) cannot be dynamic in Numbers.
    I have the same dropdown list in multiple cells and tables, and this list often needs to be changed. Its not practical to amend one list, then copy/paste it into 200 plus cells that require the dropdown facility (they are not in sequential rows).
    Can Applescript be used to do the copy/paste function, as i could specify the cell ranges. My simple attempt only managed to copy/paste the cell values rather than the dropdown/popup list.
    Any constructive help would be appreciated.
    Thanks.

    Hi Hiroto,
    I have this script running, with one issue.
    set tValues to my doThis(1) -- get values of the selection
    if tValues is not "" then
      activate
              display dialog "Select the cells where you want to create the PopUp." & return & "After that, click on the 'OK' button."
              my doThis(tValues) -- set the cell format of the new selection to "PopUp Menu" and set the values of the each menu item
              tell application "Numbers" to display dialog "Done"
    else
              tell application "Numbers" to display dialog "You must select the cells in a table before running this script."
    end if
    on doThis(n)
              tell application "Numbers"
                        set tTables to (tables of sheets of front document whose its selection range isnot missing value)
                        repeat with t in tTables -- t is a list of tables of a sheet
                                  if contents of t is not {} then -- this list is not empty, it's the selected sheet
                                            set activeTable to (get item 1 of t)
                                            if n = 1 then return value of cells of selection range of activeTable-- return values of the selection
                                            set format of (cells of selection range of activeTable) to pop up menu -- set the format to pop up menu
                                            return my setValuePopUp(n) -- set value of each menu item
                                  end if
                        end repeat
              end tell
              return ""
    end doThis
    on setValuePopUp(L)
              tell application "System Events"
                        tell process "Numbers"
                                  set frontmost to true
                                  delay 0.3
                                  set inspectorWindow to missing value
                                  set tWindows to windows whose subrole is "AXFloatingWindow"
                                  repeat with i in tWindows
                                            if exists radio group 1 of i then
                                                      set inspectorWindow to i
                                                      exit repeat
                                            end if
                                  end repeat
                                  if inspectorWindow is missing value then
      keystroke "i" using {option down, command down} -- Show Inspector
                                  else
      perform action "AXRaise" of inspectorWindow -- raise the Inspector window to the front
                                  end if
                                  delay 0.3
                                  tell window 1
      click radio button 4 of radio group 1 -- the "cell format" tab
                                            delay 0.3
                                            tell group 2 of group 1
                                                      set tTable to table 1 of scroll area 1
                                                      set tc to count rows of tTable
                                                      set lenL to (count L)
                                                      if tc < lenL then -- ** add menu items **
                                                                repeat until (count rows of tTable) = lenL
      click button 1 -- button [+]
                                                                end repeat
      keystroke return -- validate the default name of the last menu item
                                                      else if tc > lenL then -- ** remove menu items **
                                                                repeat while exists row (lenL + 1) of tTable
                                                                          select row (lenL + 1) of tTable
      click button 2 --  button [-]
                                                                end repeat
                                                      end if
                                                      tell tTable to repeat with i from 1 to lenL -- ** change value of each menu item **
                                                                set value of text field 1 of row i to item i of L
                                                      end repeat
                                            end tell
                                  end tell
                        end tell
              end tell
    end setValuePopUp
    ==============================
    When the popup is created, if there is one header row, it adds "1" to the list of popup items, if there are two header rows, it adds "1", "2" to the list of popup items. What should i amend to remove this (i have two header rows in my sheet).
    I would ideally like to add a "-" to the list (to represent nothing selected in the cell) as default i.e. top of the list (i could add the symbol to my source data but that would look untidy). At the moment, after running the script all cell values change to 1.
    Oh, what would the best way to modify the script so it selects a specific cell range? At the moment i have to first select a column, then run the script, then select the source cells, then click ok on the dialog box before it does the magic.
    Someone else will be running the script, and if its easy to change, i would prefer to have an absolute source cell range values so the user can just rund the script without any selection required.
    If you can advise on this, that would be most helpful.

  • Numbers' Functions and Formulas in Multiple Cells, Tables, and Sheets

    Hello,
    I'm stuck with specifics that center around usage, and I get the funny feeling I'm overlooking a simple detail or two.
    If I may, here goes.
    I'm working with a single spreadsheet that has several sheets within it, and each sheet has an identical table. Each table is used to record various data, and I use an additional table in a separate sheet to consolidate some of the information, so that I can track results, at a glimpse, by looking at averages, totals, etc.
    Each data table is organized for consolidation by tracking wins, ties, or losses. It is important to know that each data table only records a single win, tie, or loss along with its other applicable data. And on the actual consolidation table I am trying to tally specific data fields by the use of Numbers' functions and formulas, yet I wish to keep these tallied results organized by the determining factor of whether or not they were gathered from a table that recorded a win, a table that recorded a tie, or a table with a loss.
    To illustrate, each table contains data fields that record start time, finish time, elapsed time, the day of the week, etc. Let's say I have eight tables, and the first two are winning tables, three more are tables that record a tie, and the last three are losing tables. For example, on my consolidated data table I wish to enter a function and formula capturing which of the eight tables are wins, ties, and losses so that I can, at a glance, see how much time elapsed to obtain the wins, ties, and losses. So then, in this example, for wins I want to determine which of those wins took 20 minutes, or which of them took 15 minutes, etc. So then, out of the two wins, let's say both of them took 20 minutes each. I need the numeral 2 to be counted and recorded on the consolidation table since only two tables match the criteria. And I would do the same for all remaining data fields (e.g., start time, finish time, etc.). Just so long as everything is determined by wins, ties, and losses, and then organized by the respective data fields. Simply put, this example determines a total of two wins that meet the data field requirement of 20 minutes. Out of the eight tables (one table per sheet) any other wins would then be organized according to the specific data in the elapsed time data field on it's data table (e.g., 5 minutes, 15 minutes, etc.).
    The exact syntax structure of the functions and formula I'm unsuccessfully using follows below. It only seems to return a result of 1, and I think it is returning this value from the IF Statements. By the way, the Win, Tie, or Loss cell in each data table is cell formatted as a pop-up so I can either select None or 1. But in this example I'm basing this on the time period of 20 minutes, and out of the eight data tables I have two wins which also record the time period as 20 minutes, so I should see 2 and not 1 in the 20 minutes column of the consolidated data table. Also, I tried changing the syntax where I would type "=1" in the IF Statements, but it returned a result of =1, and if I don't include the equals sign and quotation marks the result just shows up as 1.
    My Syntax:
    IF(Trade 1::'Data Recorded (1)' '* Win', 1, IF(Trade 2::'Data Recorded (1)' '* Win',1, IF(Trade 3::'Data Recorded (1)' '* Win',1, IF(Trade 4::'Data Recorded (1)' '* Win',1, IF(Trade 5::'Data Recorded (1)' '* Win',1, IF(Trade 6::'Data Recorded (1)' '* Win',1, IF(Trade 7::'Data Recorded (1)' '* Win',1, IF(Trade 8::'Data Recorded (1)' '* Win',1, IF(COUNTIFS(Trade 1::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 2::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 3::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 4::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 5::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 6::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 7::'Data Recorded (1)' '* Time in Trade (in minutes)', "=20m")+COUNTIFS(Trade 8::'Data Recorded (1)' '* Time in Trade (in minutes)'))))))))))
    Please bear in mind that the COUNTIFS portion of the above syntax structure is something I'm already successfully using to count the totals of other things not mentioned above, and I'm hesitant to delete it since it already works to my satisfaction when I want to, for example, determine the total number of overall wins. So, just for illustration purposes, I might have an overall wins column in my consolidation table that records how many wins there are, regardless of organization by elapsed time, or any other data field. In other words, the COUNTIFS syntax structure already works to my satisfaction. I'm not sure if it's possible to alter it so that it isn't so long, but what's there does work just when counting total numbers, as just mentioned.
    In summary, I'm wondering which function I can use with the COUNTIFS function to determine which of my eight data tables are winning tables, but break those wins down further based on criteria like elapsed time, and in the above example the time elapsed is 20 minutes. As you may see above, I'm unsuccessfully using the IF function. Finally, I've looked at the function browser descriptions of things like LOOKUP, HLOOKUP, VLOOKUP, INTERSECT.RANGES, and a few others. And so far I haven't made good use of any of them the way I've done when I use the COUNTIFS function by itself when only counting overall totals. But now I must determine totals that meet certain criteria, as explained above.
    Please help if you dare (smile). This is a huge project I'm undertaking, and so as not to cause confusion I have not included all of the details. But rather, I've taken a small sampling and set it to the side for experimentation. If this small sample works out to my satisfaction I can simply copy and paste the syntax in all other respective cells in the consolidation table, changing only reference locations, and perhaps conditions or values. One thing is certain, I don't intend on giving up on it.
    Thank you for your time and advice.
    Blessings!
    Message was edited by: solo68
    Added image.

    I'd like to edit the last paragraph of my second posting, but for some reason an entirely new posting is being created when I attempt to do this. So when reading this post, please use it to replace only the last paragraph of my second post containing the four inserted images.
    Last paragraph begins:
    In closing, I need each cell in each column of each row in my consolidation table to remain as is. I have my reasons for doing this, and they all serve a specific purpose. The only exception would be the formatting of the last three rows as footer rows. Most importantly, and I should have made this abundantly clear earlier, my apologies, I need a single function and formula in cell E7 of my consolidation table that will firstly determine which data tables are winning tables while secondly and simultaneously counting which of those winning tables have elapsed times of 20 minutes. Perhaps, now this better explains why my syntax is written the way it is written. In the example I provided, if the proper function and formula were written it would result as 2 in cell E7 in my consolidation table. If there is anything else specific you need of me in order to assist me, please request it. Thank you.
    Last paragraph ends:
    Additionally, to t quinn:
    First off, thank you for returning to assist me. I really do appreciate your efforts. Please be aware that I'm avoiding going into details about each and every portion of my spreadsheet because I wish to avoid discussion that is off topic. As I stated earlier, I'm new to using these features of Numbers. My spreadsheet encompasses a much larger amount of data than I'm referring to in the example in my first post. But in my example I'm isolating just the information concerning what I'm now trying to accomplish to finish my spreadsheet project. Moreover, most of what I've done up to this point I was able to figure out on my own, or get help from watching videos on YouTube, or simply using the application help menu. Please be aware that I consulted all of these, repeatedly. I even contacted AppleCare, and was told this sort of support is not available. In spite of this, I've accomplished a great deal in my first large spreadsheet project. Please be aware that when I wrote my second post and specifically responded to you, I didn't want to be rude or ungrateful, and I still don't, but maybe the suggestions you and Hiroto made about gathering the count of wins, ties, and losses are something I've already done. I think I've done that separately. These counts are already in separate cells, and they are working fine. In my first post where I inserted only one image you can see examples of this in my consolidation table image, in cells B3 and E6. I apologize for not making this abundantly clear earlier. Furthermore, the portion of my syntax that shows the COUNTIFS is the exact way I accomplished this, and it is written the way it is written because I need separate sheets, each with their own data tables. Again, in cell E7 I need to determine which of the eight data tables that record wins are also recording 20 minutes, but I need this in a single function and formula with the result appearing only in cell E7. Once this is figured out I will adjust the syntax to do the same thing with every column (these are not shown but they exist) in my consolidation table for the last three footer rows, named Win Column Totals, Tie Column Totals, and Loss Column Totals. The last three rows being footer rows may not be necessary, and if so, I can convert them back to normal rows. Nonetheless, my consolidation table is counting the totals of all data in all data tables. This much I've already accomplished. Now I have one last function and formula I'm working on in order to determine which of the eight data tables record wins, ties, or losses while it simultaneously counts which of the wins, ties, or losses fall within certain categories like elapsed time, and this will be shown on my consolidation table only in the last three rows. Yes, I've gotten the total wins counted, and separately counted the total number of times 20 minutes was the elapsed time used, but so far, just looking at my consolidation table I don't know if the total number of times 20 minutes was used was with a win, tie, or loss. That's what I need to know now. Everything else is already accomplished. So then my consolidation table will show the totals for all data fields in my eight data tables as illustrated in cells B3 and E6. The last three rows of my consolidation table will break this down in a single function and formula with one row for wins, a second for ties, and a third for losses. And each of these respective last three rows will in the same function and formula determine if the win, tie, or loss also is one of the data fields in my eight data tables. How? By the use of columns in my consolidation table. Remember, each of my eight data tables are identical. In the example in my first post I only used one data field, elapsed time (Time in Trade), to illustrate in one column on my consolidation table what I'm trying to accomplish with all of the columns not shown in my consolidation table. Once this is figured out I can adjust it to complete the remainder of the consolidation table. Thank you, t quinn.
    To all reading this and attempting to offer assistance, if for any reason I'm still not explaining myself clearly, please continue to ask me more specific questions. I realize it's hard to communicate this way, and if Apple allowed us to upload the actual spreadsheet it would make this entire forum a better place to communicate. But that's going off topic, so let's simply focus on the matter at hand. Thank you.
    Blessings!

  • In Pages, How to copy a table? How to make a table as a Header?

    Hi, How can I copy a table? I selected it , command c, then clicked where I wanted the copy, and clicked command v. Only the text from the table was copied. The table outline did not paste.
    I would like the table to appear under the Header of every page of the document. So I tried placing the table in the Header. Worked for the first page, but did not appear in the Header of the second page ... just a really big Header box.
    Thank you for your help.
    margaretfrommb

    Hi, margaretfromn
    I'm sorry this reply may not solve your problem. I have the same problem as you.
    What I have found that tables can be copied by using "option+drag" WITHIN the document. But, the same technique do not work across documents.
    In Pages '09, there is a function to convert text to table, but it has disappeared in Pages 5 as the other convenient functions.
    Cheers,

  • How to Copy a table from mail to Numbers

    Hi,
    Today I received a mail from Exchange user. He Paste a table in to the mail and sent to me. I am using safari on Ipad 3.
    i just want to copy tat table to Numbers; whenever i try to Select "Select all" all shows selected but after copying tabel can be shown !
    Can you suggest me the way to resolve this issue.

    Edit:
    I realize I should have said: I don't know how to make Copy in Mail and Paste in Numbers work. I know how it should work, just as you believe it should work. When I try, the best I can do is a 1-column table of text, similar to what you get in OSX numbers if you Paste into the text layre of a cell rather than into a Sheet.
    Jerry

  • Auto copy cells to second sheet

    hi, good people!
    is there a way to auto copy cells in second sheet.
    i have many rows with data, i want from my sheet1 colum C copy all rows that contain name "apr" to sheet2, and if i add new row with name "apr" it will auto copy it to sheet2... is there a way to do that in iwork
    tnx!

    What you're looking for is called a "Breakout Table." Here's an example, based on your layout above, but with generated pseudo data replacing what's in your image above.
    Main represents your data table. Summary is the breakout table that collect each row of data whose date is in April, 2013.
    Formulas:
    Main contains no formulas.
    Index creates a single column list of numbers to serve as an index of rows containing data within the month noted in A1 of Summary.
    Formula in B2, then filled down the the end of the single column:
    B2: =IF(AND(OFFSET(Main :: $A$1,ROW()-1,0)>=Summary::$A$1,OFFSET(Main :: $A$1,ROW()-1,0)<=EOMONTH(Summary::$A$1,0)),MAX($A$1:$A1)+1,"-")
    Summary uses MATCH to read theindex and transfer data from all rows of Main whose date falls within the month defined by the Date and Time value in A1. (see note below). The MATCH result is used by OFFSET to determine the row of Main from which to obtain data for the current row of Summary.
    Formula:
    A2: =IFERROR(OFFSET(Main :: $A$1,MATCH(ROW()-1,Index :: $A,0)-1,COLUMN()-1),"")
    Fill right to column D, and down to the end of the table.
    Results as shown.
    Notes:
    The data in columns B, C and D are constructed to make it easy to see what row and colun that data came from.
    MATCH is set to find (exact) values. If the exace value is not found, an error message will be generated. the error is trapped by IFERROR, and a hyphen is placed in the cell.
    All dates shown including Summary :: A1, are Date and Time values, with the formatting set to not display the time part of that value. The date in Summary :: A1 is the first of the month you wish to have incuded in the summary. The cell is formatted to show only the month and year of that date.
    All functions used are listed and discussed in the Numbers '09 User Guide, which can be downloaded via the item of that name in the Help menu in Numbers '09.
    Regards,
    Barry

  • Automating Final Cut Express using AppleScript?

    Hello,
    just another question: is it possible to use AppleScript (or something similar) with Final Cut Express?
    And if so, where to find a good reference?
    I have some DV movies and a for each a csv containing the In and Out Points for the subclips, including their names and comments about the contained action, date, place, light and so on.
    At moment I'm doing everything manually, but that's time killing, so I'm looking for how to automate this.
    Thank you.

    Comma Separated Values (see http://tools.ietf.org/html/rfc4180).
    In other words: a machine readable table sheet.

  • Copy a table in Safari and paste special, as text, to an Excel worksheet

    I am attempting to write Applescript code to copy a table in Safari and paste special, as text, to an Excel worksheet.
    When I perform the operation manually, all the rows of the Safari table are pasted into Excel in a single column, i.e. after all of the data in a row of a table is pasted vertically into Excel,the next row is pasted in the next open cell below in the same column, as I need it.
    When I use the applescript line..."paste special on worksheet format text" Excel pastes the table data in rows AND columns , like the table looks in Safari, but I do not want it pasted this way.
    Any ideas on how to get my Applescript code to perform the same manual operation?
    Thanks!

    I do not know what Excel you have, but to copy a table from a Safari's page, you could use the table tags of the page's source to get the table you want.
    That is, use text item delimiters.
    deivy

  • Applescript excel copy paste repeat...

    I'm trying to set up a simple applescript to copy a cell and paste it repeatedly down the column to the last record.
    Can some one help?
    The closest I could find is this:
    tell application "Microsoft Excel"
      copy range range "I1"
      paste special range "I2:I5" what paste values
    end tell
    This works, but I need the script to determine the number of rows with data and paste that many times.

    Glad to help!
    A few things to add:
    1.  You only need a tell...end tell for the whole script as you're only addressing the one app
    2.  It would be useful to enclose the whole of the script (inside the tell Excel) in the
              tell active sheet of active workbook ... end tell
    construction.
    3.  At the end you can substitute the copy/paste special with:
              set (value of range ("F2:F" & rowCount)) to (get value of range ("E2:E" & rowCount))
    4. If you do have a header row, then the following changes in the concatenation section (but, I suppose, given that it's going to be deleted it doesn't really matter!)
      set formula of cell "E2" to "=(IF(ISBLANK(D2),,C2&\" \"&D2))"
              fill down range ("E2:E" & rowCount)
    It should end up looking like this:
    tell application "Microsoft Excel"
              tell active sheet of active workbook
      -- remove unneeded columns
                        set mycolumns to range "M:ZZ"
      delete mycolumns
                        set mycolumns to range "D:G"
      delete mycolumns
                        set mycolumns to range "A:A"
      delete mycolumns
      -- Insert 2 columns to work with
      insert into range column 5
      insert into range column 5
      --contencate addresses from C&D into E
                        set formula of cell "ZZ1" to "=MATCH(REPT(\"z\",50),D:D)"
                        set rowCount to get value of cell "ZZ1" as integer
                        set value of cell "ZZ1" to ""
                        set formula of cell "E2" to "=(IF(ISBLANK(D2),,C2&\" \"&D2))"
                        fill down range ("E2:E" & rowCount)
      -- copy a Contencated address values to column F and delete columns C, D, E
                        set (value of range ("F2:F" & rowCount)) to (get value of range ("E2:E" & rowCount))
      delete column "C:E"
              end tell
    end tell

  • Formulas Across Sheets

    I am a basketball coach and am trying to compile season statistics for 38 games. I have a 38 Sheets (one for each game) and a Sheet Labeled "Season Stats". In The "Season Stats" Sheet, I would like to do things like sum up all minutes played for a player for all 38 games. Is there a formula that would allow me to do this? My "Minutes Played" Stat for all 38 games is in the same cell "B8" on all 38 sheets.

    When it comes to referencing values contained in multiple tables (or in tables on multiple sheets), there is no concise formula like there would be if you were selecting a range of cells within one table. But what you want to do can still be done. What is unknown right now is the easiest way to do it. I can give some hints but without knowing how your tables & sheets are named, I can't provide an exact answer.
    If your sheets are consecutively numbered such as Sheet 1, Sheet 2, etc. or Game 1, Game 2, etc. it is a little simpler than if they have totally unique names. I am assuming that you have one table per sheet, all are called Table 1 and each has a column for all player names and several columns for the stats for that game. I am assuming you will create a unique summary table for each player.
    The basic idea is to have formulas that pull all of a single player's stats (from every game) into the player's summary table. Then you can more easily use them in formulas. When done, you can hide the rows of raw game stats and have only the summary stats visible. Then you can replicate (copy/paste) this table for every other player and all you'll have to do is change the player's name. Or you can copy/paste a section of the table repeatedly to lower rows if you want to do everything in one table.
    Actually, before I go on, can you describe your document more fully? If I assumed something incorrectly then I'm going to end up doing a lot of typing for nothing.
    Message was edited by: Badunit

  • Can I chart in Numbers using AppleScript

    I have just started learning AppleScript so that I can automate some business processes and save myself some time. Because of better design and ease of use I use the latest version of iWork and don't even have Office installed on my Mac, nor do I want to install it. However, one area I cannot work out is how to automate the creation of a chart in Numbers using AppleScript.
    Is this possible? If so, how, and if not, why not?

    Answering questions like : how may we do this or that, is what we are supposed to try to achieve in this forum.
    Answering questions like yours : why this or that, can't be seriously done here.
    Here you ask to end users like you. We don't belong to the teams designing the apps.
    We just may try to guess.
    To build tables and charts Pages and Numbers share the same pieces of code so there is no technical reasons able to explain the omission.
    So I guess that, as Pages is in its 4th version, designers had more time available to embed features in the AppleScript support than those working upon Numbers.
    What's funny is that there is a minimal support for charts in Pages (as well as a microscopic support for tables) but there is a correct support for tables (which may be enhanced) in Numbers but nothing for charts.
    Honestly, I really don't think that the difference is huge.
    I posted my script too fast.
    I forgot to insert the handler allowing us to bring a sheet at front which is required to apply GUIScripting.
    It's probably the main drawback of the need to use GUIScripting here.
    I don't waste time trying to apply some edit tasks to the charts.
    I just wanted to fill the gap between Pages and Numbers about scripting charts.
    Here is an enhanced version.
    --{code}
    --[SCRIPT add_charts]
    Yvan KOENIG (VALLAURIS, France)
    2011/08/27
    on run
              my activateGUIscripting()
              tell application "Numbers" to tell document 1
                        set dName to its name
                        set sName1 to name of sheet 1
                        set sName2 to name of sheet 2
    Select sheet 1 of document 1
    The doc name may be passed by a number but the sheet must be identified by its name .
    As it's just a sample, in the first call I reference the doc by its index *)
                        my selectSheet(1, sName1)
                        tell sheet sName1 to tell table 1
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 2 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 9) -- Scatter chart
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 2 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 3) -- Bars
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 2 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 4) -- Stacked Bars
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 3 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 20) -- 3D Pie
                        end tell
    Select sheet 2 of document 1
    This time, I reference the document by its name *)
                        my selectSheet(dName, sName2)
                        tell sheet sName2 to tell table 1
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 2 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 9) -- Scatter chart
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 2 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 3) -- Bars
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 2 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 4) -- Stacked Bars
    Always define the selection before creating a chart *)
                                  set selection range to range (name of cell 4 of column 3 & " : " & name of cell 8 of column 3)
                                  my selectSubMenu("Numbers", 5, 4, 20) -- 3D Pie
                        end tell --sheet 2…
              end tell -- Numbers…
    end run
    --=====
    on parleAnglais()
              local z
              try
                        tell application "Numbers" to set z to localized string "Cancel"
              on error
                        set z to "Cancel"
              end try
              return (z is not "Annuler")
    end parleAnglais
    --=====
    on activateGUIscripting()
      (* to be sure than GUI scripting will be active *)
              tell application "System Events"
                        if not (UI elements enabled) then set (UI elements enabled) to true
              end tell
    end activateGUIscripting
    --=====
    ==== Uses GUIscripting ====
    on selectSheet(theDoc, theSheet)
              script myScript
                        property listeObjets : {}
                        local maybe, targetSheetRow
                        tell application "Numbers"
      activate
                                  set theDoc to name of document theDoc (* useful if the passed value is a number *)
                                  tell document theDoc to set my listeObjets to name of sheets
                        end tell -- "Numbers"…
                        set maybe to theSheet is in my listeObjets
                        set my listeObjets to {} -- So it will not be saved in the script *)
                        if not maybe then
                                  if my parleAnglais() then
                                            error "The sheet “" & theSheet & "” is unavailable in the spreadsheet “" & theDoc & "” !"
                                  else
                                            error "La feuille « " & theSheet & " » n’existe pas dans le tableur « " & theDoc & " » ! "
                                  end if -- my parleAnglais
                        end if -- not maybe
                        set maybe to 5 > (system attribute "sys2")
                        tell application "System Events" to tell application process "Numbers"
                                  tell outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window theDoc
                                            if maybe then (* macOS X 10.4.x
    '(value of attributes contains 0)': '(value of attribute "AXDisclosureLevel" is 0)' sometimes works in Tiger, sometimes not.
    The only possible instances of 0 amongst the attributes are the disclosure level of a sheet row and the index of the first row, which represents a sheet anyway.
    Another possibility is '(value of attribute -1 is 0)', which makes me uneasy. *)
                                                      set targetSheetRow to first row where ((value of attributes contains 0) and (value of first static text is theSheet))
                                            else (* macOS X 10.5.x or higher *)
                                                      set targetSheetRow to first row where ((value of attribute "AXDisclosureLevel" is 0) and ((groups is {}) and (value of first static text is theSheet)) or (value of first group's first static text is theSheet))
                                            end if -- maybe…
    Handler modified to accomodate sheets requiring a lot of time to get the focus
                                            tell targetSheetRow to set value of attribute "AXSelected" to true
                                            set cnt to 0
                                            repeat (*
    Must way that Numbers becomes ready to receive the value *)
                                                      try
                                                                tell targetSheetRow to set value of attribute "AXDisclosing" to true
                                                                exit repeat
                                                      on error
                                                                set cnt to cnt + 1
      delay 0.5 -- half a second
                                                      end try
                                            end repeat
                                  end tell -- outline…
                        end tell -- "System Events"…
                        tell application "Numbers" to tell document theDoc to tell sheet theSheet to tell table 1
                                  with timeout of 20 * 60 seconds (*
    WITH this setting, the script will be able to wait 20 minutes for the asked value.
    I hope that the document will not be so huge that this delay prove to be too short. *)
                                            value of cell "A1"
                                  end timeout
                        end tell -- "Numbers"…
                        tell application "System Events" to tell application process "Numbers" (*
    Do the trick one more time to be sure that the sheet is open *)
                                  tell targetSheetRow to set value of attribute "AXDisclosing" to true
                        end tell -- "System Events"…
    End of the modified piece of code
              end script
      run myScript
    end selectSheet
    --=====
    my selectSubMenu("Pages",6, 4, 26)
    ==== Uses GUIscripting ====
    on selectSubMenu(theApp, mt, mi, ms)
              tell application theApp
      activate
                        tell application "System Events" to tell process theApp to tell menu bar 1 to ¬
                                  tell menu bar item mt to tell menu 1 to tell menu item mi to tell menu 1 to click menu item ms
              end tell -- application theApp
    end selectSubMenu
    --=====
    useful to get the indexs of the triggered item
    my select_SubMenu("Numbers", 6, 4, 3) (* Table > Chart> Bars *)
    on select_SubMenu(theApp, mt, mi, ms)
              tell application theApp
      activate
                        tell application "System Events" to tell process theApp to tell menu bar 1
                                  get name of menu bar items
    01 - "Apple",
    02 - "Numbers",
    03 - "Fichier",
    04 - "Édition",
    05 - "Insertion",
    06 - "Tableau",
    07 - "Format",
    08 - "Disposition",
    09 - "Présentation",
    10 - "Fenêtre",
    11 - "Partage",
    12 - "Aide"}
                                  get name of menu bar item mt
      -- {"Tableau"}
                                  tell menu bar item mt to tell menu 1
                                            get name of menu items
    01 - "Feuille",
    02 -  missing value,
    03 - "Tableau",
    04 - "Graphique",
    05 - "Figure",
    06 - "Zone de texte",
    07 - "Fonction",
    08 - "Ligne de connexion",
    09 - missing value,
    10 - "Remplissage",
    11 - missing value,
    12 - "Rangs copiés",
    13 - "Colonnes copiées",
    14 - missing value,
    15 - "Date et heure",
    16 - "Nom du fichier",
    17 - "Numéro de page",
    18 - "Nombre de pages",
    19 - missing value,
    20 - "Commentaire",
    21 - "Lien",
    22 - "Saut de colonne",
    23 - "Équation MathType",
    24 - missing value,
    25 - "Choisir…"}
                                            get name of menu item mi
      --> "Graphique"
                                            tell menu item mi to tell menu 1
                                                      get name of menu items
    01 - "Colonnes",
    02 - "Colonnes empilées",
    03 - "Barres",
    04 - "Barres empilées",
    05 - "Ligne",
    06 - "Couches",
    07 - "Couches empilées",
    08 - "Diagramme circulaire",
    09 - "Nuage de points",
    10 - "Mixte",
    11 - "2 axes",
    12 - missing value,
    13 - "Colonnes 3D",
    14 - "Colonnes 3D empilées",
    15 - "Barres 3D",
    16 - "Barres 3D empilées",
    17  - "Linéaire 3D",
    18 - "Couches 3D",
    19 - "Couches 3D empilées",
    20 - "Circulaire 3D"}
                                                      get name of menu item ms
      --> "Barres"
      click menu item ms
                                            end tell
                                  end tell
                        end tell
              end tell -- application theApp
    end select_SubMenu
    --=====
    --[/SCRIPT]
    --{code}
    Yvan KOENIG (VALLAURIS, France) samedi 27 août 2011 15:19:15
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

Maybe you are looking for

  • 6.0 Professional and windows 8.1

    I just loaded Acrobat 6.0 Pro to my new windows 8.1 computer, but I can't open it because of some compatibility issue. Is there a fix for this? Thanks

  • Strange file sharing issue - need guru!

    I know how file sharing works.  This isn't a basic problem. I have a volume with a folder containing music files that I want to share to a Windows 7 PC.  I turned on sharing and it worked just fine, EXCEPT that I couldn't set the permissions to read

  • Error encountered fatal error installation

    I'm trying to install Acrobat Reader Pro but it gaves me this error. I have a PC.

  • Reset and reverse for various vendor groups.

    Hello, We have two distinct vendor groups. For Group A there is no tax implications. For Group B withholding tax is mandatory. When we are trying to run TCode FBRA for the Group A vendors, we find that it's giving me the option of 'Reset' and 'Reset

  • Saving forms with interactive fields.

    I am using Adobe Reader XI.  I am filling out a form with interactive fields and the purple bar at the top which states "data typed into this form can be saved".  However, when I save the form and then reopen it, the form is blank.  Is there anything