Applescript on Numbers to copy rows between tables

Hi,
I am an applescript newbie, but am trying to make my book-keeping spreadsheet a bit more comfortable. And this is the problem:
I have expenses that repeat every month and I would like to not have to rewrite them each time. So I thought I make a second table where I list all the repeating data and copy them into my main table. This works simply with selecting the row and then copy and paste in to the row of the main table.
But I would like to make it nicer, and my concept is to make this copy process simpler, by memorizing the row number of the second table, (e.g. row 5 contains the rental costs for my studio ), so I would select the last row and then type the number of the expected row in table 2 and have the content be automatically copied into the selected row of table 1 (main table).
I got the script to do so except the shortcuts for the keys. And I have no idea how to make the script understand that if I press the key for number "5" to start copying row 5 of table 2 into the last row of table 1. Here is my script as far as I got (it is far from finished I know, it is a test with 4 columns named "Art des Umsatzes", "Kategorie", "Projekt", "Betrag".
If anyone could give me advice ho to define that the keystrokes become variable b and d, I think I would be able to manage the rest.
Many thanks
Hans Peter
              tell application "Numbers"
                           tell table 2 of sheet 1 of document 1
                                     set a to b
                                     set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                     set tagValues to {}
                                     set theRange to "B" & a + 1 & ":" & "G" & a + 1
                                     set C to 1
                                     set setArt to value of cell C of range theRange
                                     set C to (C + 1)
                                     set setKat to value of cell C of range theRange
                                     set C to (C + 1)         
                                     set setProj to value of cell C of range theRange
                                     set C to (C + 1)
                                     set setBetr to value of cell C of range theRange   
                           end tell
                           tell table 1 of sheet 1 of document 1
                                     set a to d
                                     set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                     set tagValues to {}
                                     set theRange to "B" & a + 1 & ":" & "G" & a + 1
                                     set C to 1
                                     set value of cell C of range theRange to setArt
                                     set C to (C + 1)
                                     set value of cell C of range theRange to setKat
                                     set C to (C + 1)
                                     set value of cell C of range theRange to setProj
                                     set C to (C + 1)
                                     set value of cell C of range theRange to setBetr
                          end tell
               end tell

Hi HD
thanks for your prompt and very helpful response. Although I had to add some more, your suggestion paved the way. Your simpler suggestion with the reference does not really work (sorry.)
This is the solution. what you need to do is make 2 table. The first on has one row (title row) and 5 columns (first is title again). The second has 6 rows (one title) and 5 columns (first one title). then you fill in each of the cells a word or number.
Run the script and choose one of the 5 numbers, one row will be added and filled. That's what I hoped to get, only I cannot type, I have to click the number. That is a bit a shame, do you think Automator could make a bridge to connect the script number to the keys?
Well, anyhow. Thanks again for your great help.
All the best, Hans Peter
           tell application "Numbers"
                           tell table 2 of sheet 1 of document 1
                                     set b to (choose from list {1, 2, 3, 4, 5} with prompt "Nummer des Schlüssel")
                                     if the result is false then return
                                     set a to b as integer
                                     set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                     set tagValues to {}
                                     set theRange to "B" & a + 1 & ":" & "G" & a + 1
                                     set C to 1
                                     set setArt to value of cell C of range theRange
                                     set C to (C + 1)
                                     set setKat to value of cell C of range theRange
                                     set C to (C + 1)
                                     set setProj to value of cell C of range theRange
                                     set C to (C + 1)
                                     set setBetr to value of cell C of range theRange
                           end tell
                           tell table 1 of sheet 1 of document 1
                                     set d to count row
                                     add row below last row
                                     set d to d + 1
                                     set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                     set tagValues to {}
                                     set theRange to "B" & d & ":" & "G" & d
                                     set C to 1
                                     set value of cell C of range theRange to setArt
                                     set C to (C + 1)
                                     set value of cell C of range theRange to setKat
                                     set C to (C + 1)
                                     set value of cell C of range theRange to setProj
                                     set C to (C + 1)
                                     set value of cell C of range theRange to setBetr
                           end tell
          end tell

Similar Messages

  • How to copy data, table rows between tables in different schema

    how do I copy rows from one table in one schema into another table in another schema in same database?

    Hi,
    Give an Access to the respective table in Source Schema to Destinations Schema. If table does not exits in the destination schema use CTAS else Insert into..etc., with your select Query.
    - Pavan Kumar N

  • Copying data between tables - numbers on an ipad

    I have two [main] lists (tables):
    Workers names, photos, arrival times, training record and other data on one table (the 'Workers List') with one worker's data on each line.
    The other table (really a set of 3)  of three 'shift sheets', Red, Green and Neutral listing who is on-duty at any given time.
    What I'm trying to do - on an iPad - is allocate each worker to a R,G or N shift by making an entry on their row in the Workers List, and have their name and photo (cells from columns B and C in the Workers List) copied automatically to the next available empty row in the relevant one-of-three shift sheets.
    As I see it there are two main problems: the 'cut and paste' aspect which I can just abut get a handle on, and the selection of the next empty row in the coreect (1 of 3) sheet - which has me baffled.
    I'd really appreciate any thoughts.
    Nick
    (if anyone's even remotely interested, this is for organising the staff at the Incredibly-Famous Cider Bus at Glastonbury Festival!! - a free jar for the problem solver!)

    ok, my solution gets a little complicated and I dont know if it would work for the pictures at all.
    I would have three columns Marked as R, G or B. These would eb equations that look at your column that has R, G or B entered. These increment by one if the letter for that column is found on that row.
    Then in my "color" tables, I have an equation that uses an offset and a match to locate the next row for that color.
    Heres a table for an example(with formula results):
    1
    a
    R
    1
    b
    G
    2
    c
    R
    3
    d
    R
    3
    e
    G
    Column A increments every time R appears in C
    then in the Color R table we use this in cell A1 to pull back the data in the first rows column B that has an R (row 1 in this case)
    =offset(table1::$B$1,match(row(),table1::$a,0)-1,0,1,1)
    this looks for the number 1 in column A, returns what row that was found on, offset from B1 that number minus 1. grab a range 1x1, ie. one cell.
    Just modify this to pull back as many different columns you need. It will show #N/A when you hit the last row for R, just delete those and remove the extra rows from displaying in your table. exapnd when you add more.
    Repeat this with an additional column for G and B, and modify the equation for referencing thier counter columns. the first row in your G table will pull back the information from row 2 in my table above.
    Let me know here if this makes sense. its the only way I could find of doing something similar in XL at work.
    Thanks
    Jason
    Message was edited by: jaxjason

  • Comparing two columns in two tables using partial text strings and copying data between tables

    I have two tables:
    The Vendor table is supplied by a clothing manufacturer and lists product data by row with a column that contains a unique manufacturer ID, such as T5C4.  In this table is a short product description and a long product description that I need to find and copy into the second table, Inventory.
    The Inventory table is an export from our Magento store.  Each row contains a unique inventory number in a column that includes but does not match the unique manufacturer ID from the Vendor table.  For example, the unique inventory number could be T5C4-W12, or RED-T5C4W12 or some other variation.
    For each product in Inventory, I need to find the matching product in Vendor, and then copy the short description and long description from Vendor to Inventory.
    Any tips?  Thanks!
    Karl

    Karl,
    Here's a start, as you requested.
    The formula for Our Inventory Row is:
    =IFERROR(MATCH("*"&A&"*", Our Inventory :: A, 0), "n/a")
    The formula for Brief Description in the inventory table is:
    =IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 2), "n/a")
    The formula for the Full description in the inventory table is:
    =IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 3), "n/a")
    The Manufacturer's table knows the concise product numbers, so it has the ability to search the Inventory table for it's product id's using wildcards and it then displays the line number of the item in the inventory table. The Inventory table can then search the manufacturer's table for its row number and can reference the brief and full descriptions.
    This approach has a serious limitation. It will only find the first occurrence in the inventory. Now, if you want to accept this, you can sort all the found descriptions and pull them out of the inventory table, and then the next product in line will display it's description too.
    I wish I could do better with this, but it's all I can come up with at this point, knowing only what you have told me.
    Jerry

  • Drag and Drop rows between tables in JSP

    I have to convert a swing application into a web project. One of the screens in my swing application uses drag and drop of records between two tables. The key is that when one of the rows is picked and dropped in the other table values get allocated to each column accordingly. I need to bring this functionality into a JSP. There is no constraint on using Javascripts. Please help me asap.
    Regards,
    KK

    Yes it is possible, but not so easy. If you'll be at OOW this year, you can come to my session (S301752, Monday 13:00-14:00) - I will show something similar there. If you're not so lucky, you can read the excellent blogpost of my colleague at [http://rutgerderuiter.blogspot.com/2008/07/drag-planboard.html]
    Cheers
    Roel

  • Copying data between tables

    I have just completed the process of exporting my companies
    main mailing database into a new database file which is setup and
    structured differently. I am trying to figure out how to run a
    coldfusion query that can update my contact information from one
    table into another, tables are as follows:
    companies table
    companyid | contacttitle1 | contactname1 | contactsurname1 |
    contactposition1 | mail1
    autonum | text | text | text | text | text
    AddxContacts table
    id | contacttitle1 | contactname1 | contactsurname1 |
    contactposition1 | mail1
    number | text | text | text | text | text
    i need to update the fields in the first table with the
    fields in the second table, the companyid & id from each table
    are the primary keys that match up the records, however the
    AddxContacts table may contain more than one entry with the same id
    no, but i only want to copy one record for each id no.
    I have scoured various forums looking for an easy way to do
    this but so far have come up blank, any help would be greatly
    appriciated. Thanks

    There is a major difference between what you say you intend
    to do and what your sample code indicates you are attempting to do.
    Do not store contact information in your company table. Put
    it elsewhere with either a one to many or many to many relationship
    set up, depending on your business requirements.

  • Matching rows between tables

    I have two tables:  t1 and t2
    t1 has a larger number of rows than t2.
    I want to know:
    1. If there are no rows in t2, and
    2. If all the rows in t2 exist in t1
    I have tried to do this using a CASE statement, but I am getting errors.   Here is the sample:
    Create Table #t1 (Fname varchar(25));
    Create Table #t2 (Fname varchar(25));
    Insert into #t1
    Values ('ABC'),('DEF'),('GHI'),('JKL'),('MNO');
    Insert into #t2
    Values ('DEF'),('MNO');
    Select
    Case
    When (Select count(*) From #t2) = 0 Then 'No rows'
    When Count(SELECT fname FROM #t2 INTERSECT Select Fname from #t1) = (Select count(*) From #t2) Then 'Success'
    ELSE 'Fail'
    END AS fname;
    drop table #t1;
    drop table #t2;
    Thanks for your help !
    MisterT99

    Try:
    SELECT CASE
    WHEN NOT EXISTS (
    SELECT 1
    FROM #t2
    THEN 'No Rows'
    WHEN NOT EXISTS (
    SELECT 1
    FROM #t1 t1
    LEFT JOIN #t2 t2 ON t1.fname = t2.fname
    WHERE t2.fname IS NULL
    THEN 'Success'
    ELSE 'Fail'
    END AS fname
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Problem copying data between tables

    Hello Members,
    Its my first day using SQL queries on oracle 10g database.I used the following query to copy selected feilds of a table :
    CREATE TABLE SAMPLE_TEMP as (SELECT CUSTOMER, BALANCE FROM CUSTOMER_ALL)
    The CUSTOMER_ALL table has over 2 million records. I was successful in creating a table and copying data, but the new table could populate only 52978 records.
    ---- Sample data in my table
    CUSTOMER     BALANCE
    6.28899273     0
    6.28899274     0
    6.28899275     0
    6.28899289     625.12
    6.28899292     2666.24
    How do I go about fixing this ? Do i need to declare a structure and assign the number of records i will store to it ? Any guidance will help me get started.
    Regards
    newbie

    Hello,
    If the CUSTOMER_ALL table is a live table, there may have been new records INSERTed since you copied the data, therefore you will have different counts.
    To check on the data difference:
    SELECT CUSTOMER, BALANCE FROM CUSTOMER_ALL
    MINUS
    SELECT CUSTOMER, BALANCE FROM SAMPLE_ALL

  • Worklist table ponits to the first row after copy row

    Hi experts,
    We have installed ESS BP 1.41 into EP version 7.02. Now we found one issue in the ESS Working Time application screen.
    The screen has an option of copying rows from Worklist Table on top to the bottom table having Weekly/Daily view.
    The problem is if we choose recoreds from the top table and press the button 'Copy Rows' the table gets re-sorted and again points to the first row.
    When there are hundreds of entries in that table, it becomes difficult for the user to see the rows selected for copy immediately after pressing the Copy Rows button.
    Can anyone help to stop this sorting.
    Regards
    Arindam

    Hi Siddharth,
    many thanks for your reply. One doubt in BP 1.41, it is a WD java application, but the note you suggested, talks about the Ehp5 version which is in WD abap. Can you please re check and confirm.
    Regards
    Arindam

  • Copy entity between EntityManagers - Exception TOPLINK-7251

    I am trying to copy rows from one database to another using Toplink. The tables have a composite primary key. Sample.java copies over three thousand rows successfully before an exception.
    h3. Configuration
            <persistence-unit name="STLMOSQL">
              <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
              <class>jpa.Ineligiblereasonxref</class>
              <class>jpa.IneligiblereasonxrefPK</class>
         </persistence-unit>
         <persistence-unit name="DataWareHouse">
              <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
              <class>jpa.Ineligiblereasonxref</class>
              <class>jpa.IneligiblereasonxrefPK</class>
         </persistence-unit>
              </properties>
         </persistence-unit>h3. Sample.java
       public static void main(String[] args) {
          EntityManagerFactory emf1 = Persistence.createEntityManagerFactory("em1");
          EntityManager em1 = emf1.createEntityManager();
          EntityManagerFactory emf2 = Persistence.createEntityManagerFactory("em2");
          EntityManager em2 = emf2.createEntityManager();
          try {
             Query q = em1.createQuery("Select i from Ineligiblereasonxref i") ;
             List<Ineligiblereasonxref> xrefs = (List<Ineligiblereasonxref>) q.getResultList();
             em1.clear();
             for(Ineligiblereasonxref xref :  xrefs){
                  em2.getTransaction().begin();
                  em2.merge(xref);
                  em2.getTransaction().commit();
          }finally {
              em2.close();
              emf2.close();
              em1.close();
              emf1.close();
       }h3. Ineligiblereasonxref.java
    @Entity
    public class Ineligiblereasonxref implements Serializable {
         @EmbeddedId
         private IneligiblereasonxrefPK pk;
         private String ineligiblereasoncode;
            ... deleted ...
    }h3. IneligiblereasonxrefPK.java
    @Embeddable
    public class IneligiblereasonxrefPK implements Serializable {
         private String sourceineligiblereasoncode;
         private long datasourceid;
         private long sourcetableid;
            ... deleted ...
    }h3. Exception
    Exception [TOPLINK-7251] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: The attribute [sourceineligiblereasoncode] of class [jpa.IneligiblereasonxrefPK] is mapped to a primary key column in the database. Updates are not allowed.
         at oracle.toplink.essentials.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2222)
         at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:750)
         at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRowWithChangeSet(ObjectBuilder.java:837)Edited by: timmaryson on May 11, 2009 1:52 PM

    Thanks for the reply Chris. I actually had tried this, but it didn't help. I did find the problem though. Maybe someone else may run into this in the future, so I will explain.
    I am copying rows between databases with different character set collations. The first database is case sensitive. The second database is case insensitive.
    The first database has one row with the key '1,394,CM' and and another row with the key '1,394,cm'. The second database treats these as the same.
    merge() flags this as an error when it notices that the combination of the new and old objects yields a new key.
    I changed the collation to be case sensitive on MS SQL Server. [http://msdn.microsoft.com/en-us/library/aa258233(SQL.80).aspx]
    CREATE TABLE  INELIGIBLEREASONXREF (
        SOURCEINELIGIBLEREASONCODE varchar(10) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
    )CP1 - Default code page
    CS - Case Sensitive.
    AS - Accent Sensitive
    I am interested to know if Toplink's behavior is "correct". Some users may wish to configure this behavior.
    I did not find any reference to collation nor case sensitivity in "JSR 220: Enterprise JavaBeansTM,Version 3.0
    Java Persistence API" nor in TopLink. JDBC reports the column's case sensitivity. So the potential is there to extend Top Link.
    Thanks again for the reply,
    Tim
    Edited by: timmaryson on May 11, 2009 12:29 PM
    Edited by: timmaryson on May 11, 2009 1:52 PM
    Edited by: timmaryson on May 11, 2009 2:07 PM

  • How to copy data between two tables row by row

    Hi All,
    I have three tables TableA and TableB and TableC
    I wanted to write a stored procedure to copy data row by row from TableA to TableB and then update TableC by replacing any record that has the old id (before copying) to the new id after copying the data.
    here is the steps 
    iterate throw all the rows in tableA ( probably with a foreach)
    in each iteration we will do the following:
    Get current ID (identity) for each record in TableA ( will call it @oldID)
    Insert the row in TableB
    Get the new ID for the row from TableB will call it (@NewID)
    find rows in tableC that has the (@oldID)
    replace all ids in tableC with @oldID to @NewID
    Thanks in advance

    0
    TableA and TableB are identical they should have the same columns 
    TableC columns will be ( ID, TableA_ID , Notes)

  • How can I get Numbers to copy the formatting of a table?

    I am trying to replicate the AppleWorks spreadsheet that I created to do my monthly finances
    My AppleWorks spreadsheet has lots of defined ranges that I'm turning into separate Numbers Tables (so I have to change Many Many Many cell references, which does not seem to be easy in Numbers)
    I've formatted one table as I want it - columns for itemizing expenses for the month with column to describe expense. I've got a header column (e.g. "Hobbies") that I'm centering (merge Cells) over the 2 columns for month's expenses and descriptions. Month's expenses columns are narrower than the description columns.
    I've tried selecting the table and saving as a named style.
    Then, when I create the next table, it starts w/ generic formatting. I clear and apply the style I've just created - _some_ of the formatting is applied to the new style, but not all:
    Fill in the header row not applied
    Merged cells in the header row not applied
    Tinted fill in header row not applied
    Centered text of Merged Cells not applied (left justified, instead)
    Centered text of Months not applied (again, left justified)
    Row heights not applied
    Is there any way to copy ALL of the formatting of a table and apply it to another table?

    Thanks Wayne - I've been working on my AppleWorks to Numbers comversion  using the Apple key - D method to duplicate tables.
    I do have to retype column headers (these change for each table)
    If I could paste formatting, I could copy the entire table from imported spreadsheet, paste formatting, and Wah-Lah.
    Oh, Well the Apple Key - D method (re-entering column heads - type once and then Ctrl-C & a bunch of Ctrl-Vs) is WAY easier than reformatting each table manually.
    Only slightly painful to have to re-enter all the cell references for the summed-column totals in the sub-tables into the main table
    I've been using the same spreadsheet (w/ minor tweaks from year to year) for the past 12 years... it ain't broke & I'm grumpy about fixing what Apple broke - computers are such timesavers... sigh
    Win

  • How do I keep table relations from Numbers when copying them to Pages ?

    I have two tables within Numbers (because I need two different formats) and have connected them with a formula in Numbers. This works fine.
    But when I copy the two tables to a Pages document, the link between the tables is broken, i.e. if I modify a value in table 1, the corresponding value in table 2 is not modified.
    What can I do to keep the link between the tables inside Pages ?
    Bernhard

    Question asked and answered many times.
    There is no link between tables in Pages.
    Build your complete document in a Numbers Sheet and the problem will be solved.
    Yvan KOENIG (VALLAURIS, France) dimanche 7 août 2011 16:44:47
    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 !

  • Add new row in table between two rows - OATableBean

    Hi,
    I have a requirement where I need to add a new row between two rows. Lets say I have a table with 5 rows. I am envisioning having an icon (table switcher) on the row #1, which when clicked will insert/create a new row between rows #1 and #2 like #1.5, something that can be achieved in core forms. In core forms, when we click the add button, it immediately creates a new row before the current row ( and pushes other rows down). Is that possible with OATableBean. Please let me know if you have any ideas.
    Thanks,
    Ravi.

    Hi,
    I used following code to insert the row in the end
    public void createNewRow()
    XXEGASRLinesVOImpl vo =getXXEGASRLinesVO1();
    Row row1 ;
    int i;
    Row row[] = vo.getAllRowsInRange();
    row1 = vo.createRow(); //vo.createRowSet("10");
    vo.insertRowAtRangeIndex(row.length,row1);//.insertRow();
    row1.setNewRowState(Row.STATUS_INITIALIZED);
    Check if it works for you, you have to modify it to meet your requirement.
    Regards,
    Reetesh Sharma

  • How do I remove a gap between table rows in InDesign?

    I need help in figuring out how to remove gaps between table rows.  I have tried Table Spacing under Table Set-up, but it doesn't work.
    Here's what I'm working on:
    As you can see there are gaps above the first row and below last row under the header Business Management Technology.  I cannot select that gap.  How do I remove it, so that the first class, 31058, is flush with the black header?  (and the last class, 32675, is flush with the Chemistry header?)
    Any advice would be greatly appreciated.
    Thanks,
    Sarah 

    SRiegel wrote:
    ...it may be that the black bar is created with a paragraph rule instead of cell color.
    I hadn't considered that, and your example is proof-of-concept. However, now that you made me look closer, I still don't think that's the OP's case, seeing as the text in the OP's header rows appears to span more than one column, belying what I suppose must be merged cells.* The column strokes in the "gap" appear to disqualify it (the gap) as part of a row with merged cells.
    *There is still another possibility that someone "made pictures" of tables with merged cells by overlaying text frames to make the header rows. I've run across all kinds of such "carpentry;" especially when the file may have originated at the desk of someone who avoids or resists use of tables. They find ways to fake them and/or their features.
    [still looking]

Maybe you are looking for

  • December update fixes AJA output

    I just got updates to CC this morning. Kona3 now outputs to my broadcast monitor.

  • Cannor connect to bb app world

    Please help me. When I want to go into my bb app world on my phone I get the following IRRITATING MESSAGE: We cannot connect you to BlackBerry App Worls. Please ensure that your device is connected to the wireless network and try again. Then after wa

  • Cant access my iphoto library with finder

    Hi everyone, i installed ilife 08 and since that, i cant find my photos with finder/pictures. I only have the iphoto logo Someone can help me ? Thkx

  • Network Adapter for K450e

    How easy (or difficult) is it to install a network adapter card into a k450e?  Any recommendations for brands and models?

  • MASS COMPILING

    IN PROJECT BUILDER, IS THERE WAY TO "MASS" COMPILE ALL FORMS,RPTS...ETC WITHOUT HAVING TO COMPILE INDIVIDUALLY?