Need an applecript to copy filtered cells from a Numbers table to another Numbers file

Hi,
I would like to be able to build a new table in an existing file based on a filtered selection.
My file covers the whole year and have many more columns but let's make a short example:
Starting table: Table 1 Sheet 1 file 1
Date
Quantity
Price
Action
Port
10/3/2014
1050
100
IN
Venice
11/3/2014
35
104
CES
Venice
16/3/2014
2045
90
IN
Barcelona
21/3/2014
545
9
CUS
Barcelona
25/3/2014
50
123
CES
Venice
28/3/2014
50
21
CUS
Rome
I would like to have on a separte file(table 1 Sheet 3 File 2) a table like this (filtered by Action: IN + CUS and Port: Venice + Barcelona)
Date
Quantity
Price
Action
Port
10/3/2014
1050
100
IN
Venice
16/3/2014
2045
90
IN
Barcelona
21/3/2014
545
9
CUS
Barcelona
Any help?

Although I would have preferred to have a script beacuse the data origin file - let's call it STORAGE - is already quite heavy and I would like to use the filtered data on a separate file - let's call it MANAGEMENT - for further analysis and integration with other data coming from other STORAGE files and from other company areas.
Hi Paolo,
Below is a script that should do what you want. (Tested in Numbers 3.2). Copy into AppleScript Editor, set up the Numbers documents as indicated (or change the script to match your document setup), and click the green triangle 'Run' button.
It assumes you have both the source document ("Storage.numbers") and target document ("Management.numbers") open and that you have already set up the target table with 1 header row.  You can change your filter columns and values and filter logic where indicated.
For simplicity (and also to avoid apparent Numbers bugs in removing rows via AppleScript) I assumed the user will manually check to make sure that the target table does not contain too many rows. It needs at least 2 rows to work properly as the results are inserted starting in cell A2 (which can be changed as needed).
SG
--filters a table and passes the results to an existing table in the same or different document
--set filter column and values to filter for here:
property filter1 : {colNum:4, filterFor:{"CUS", "IN"}}
property filter2 : {colNum:5, filterFor:{"Barcelona", "Venice"}}
--set properties of source's and target's document, sheet, table here:
property source : {d:"Storage.numbers", s:"Sheet 1", t:"Table 1"}
property target : {d:"Management.numbers", s:"Sheet 1", t:"Table 1"}
tell application "Numbers"
          activate
          set filteredList to {}
           --load source table's values into a list of lists
          try
                    set valuesList to value of document (source's d as string)'s ¬
                              sheet (source's s as string)'s table (source's t as string)'s ¬
                             rows's cells
          on error
                    display dialog "Having trouble. Does your source document, sheet, and table exist?"
          end try
           --create filtered list of lists
          tell valuesList to repeat with anItem in items
                    --if needed, logic can be changed to 'not in', etc.
                    set satisfiesFilter1 to anItem's item (filter1's colNum) is in filter1's filterFor
                    set satisfiesFilter2 to anItem's item (filter2's colNum) is in filter2's filterFor
                    --if needed, logic can be changed here to 'or', etc.
                    if satisfiesFilter1 and satisfiesFilter2 then ¬
                              copy anItem's items to end of filteredList
          end repeat
          if (count filteredList) = 0 then display dialog "No rows meet your criteria" buttons "Cancel"
           --load values into target table (in this or another document, as specified in properties above)
          try
                    tell document (target's d as string)'s sheet (target's s as string)'s ¬
                              table (target's t as string)
                             --load the values into the cells starting at cell A2:
                              set pasteStr to ""
                              set {oTid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tab}
                              repeat with anItem in filteredList's items
                                        set pasteStr to (pasteStr & anItem as string) & return
                              end repeat
                              set the clipboard to pasteStr
                              set the selection range to cell "A2" --assumes 1 header row
                              tell application "System Events" to keystroke "v" using {option down, shift down, command down}
                    end tell
          on error
                    display dialog "Having trouble. Does your target (destination) document, sheet, and table exist?"
          end try
end tell
--end of script

Similar Messages

  • Copy and Modify from one internal table to another.Please help.

    Hi,
    I have an internal table having a structure like below.
    Account Entity Category period1value pd2value
    10 A C 100 200.
    where account corresponds to 10
    entity A
    category C
    period1 value = 100
    period2 value = 200.
    Now I need to populate it into another table having structure like
    Account Entity Category period Value
    10 A C 1 100
    10 A C 2 200.
    If u see this carefully a new column, period is added in the database table and thus for each row there will be only 1value.
    Instead of period1 value and period2 value being in the same row they will come in different rows.One row will be like the value for period1 and next for value like period2.
    Pleadse help
    Ankit

    Hi,
    u can do as follows,
    LOOP AT itab1 into wa_itab1.
    wa_itab2-account = wa_itab1-account.
    wa_itab2-entity = wa_itab1-entity.
    wa_itab2-category = wa_itab1-category.
    if not wa_itab1-period1 is initial.
    wa_itab2-period = wa_itab1-period1.
    endif.
    if not wa_itab1-period2 is intial.
    wa_itab2-period = wa_itab1-period2.
    endif.
    wa_itab2-value = wa_itab1-value.
    append wa_tab2 to itab2.
    clear:wa_itab1-period1 ,
           wa_itab2-period .
    endloop.

  • After updating numbers and pages I can no longer copy multiple cells from numbers and paste and match style to pages.

    After updating numbers and pages I can no longer copy multiple cells from numbers and paste and match style to pages.  I used to be able to select multipule cells in a row (such as company name, address, etc.) then paste and match style on to a pages letter. I found the paste and match style option in the edit menu, however it will only work one cell at a time. Before the update is was working great.

    For diagnosing purpose thy the procedure in a new user account and see if it works there. You create a new user account in the System Preferences > Accounts. If it works in the new account it is probably a corrupt plist file that needs to be deleted.

  • I need to move my copy of CS6 from my old computer to a new one.  Do I need my license reset?

    I need to move my copy of CS6 from my old computer to a new one.  Do I need my license reset?

    You are allowed to have the software installed and activated on two machines, so there is nothing you need to do other than install (not move) the software on the new machine, unless you already have it activated on two machines. 
    If you do not plan to use the old machine again or would simply prefer to remove the software from it, or you would like to retain an activation for another machine at some point, it is best that you deactivate it beforehand.  To deactivate open one of the applications and choose Help -> Deactivate.  Once you deactivate it there is nothing else you need to do unless you want to uninstall it as well to gain more drive space.

  • Copy a program from one sap system to another

    hi all,
       i need to copy a program from one sap system to another..along with the text symbols, selection-texts and includes without any transport request release...how can i do that?
    thanx in adv

    Hi,
    You need to Download the Program first in to Local desktop then upload the same to another server, we can not move the code directly from a server to another server without a Transport request.
    but you can call the program from other server using RFC destination, create a RFC for that server and create a function module in the server which the program is there and use the SUBMIT statmet in that function module, then from the other server call this function module using RFC destination
    Regards
    Sudheer

  • How do I copy an image from one Keynote presentation to another one?

    I have a previously saved presentation on Keynote in iCloud. I created it from my desktop at work. Some of the images I used for the presentation I want to use again in another presentation, onlh this time I am working off my laptop and don't have the same access to those images. Is it possible to copy/paste images from one Keynote presentation into another? I can't even seem to click on the image and save it.
    Any suggestions?

    Clicking and dragging does not work.
    Click on the image and Copy and Paste
    or
    Inspector > Metrics > File Info > click on the icon of the file and drag it to your desktop
    You can then drag that file back in wherever you want.
    Peter

  • Copying a page from one picture book into another

    Does anyone know how to copy a page from one picture book into another. I have made 2 books and would like to make a third consisting of pages from the first 2 but seem unable to do it without starting again, or at least starting from a duplicate of one and re doing all the missing pages.

    Garageclan
    Welcome to the Apple user to user assistance forums
    print each page you want to include in "book 3" to a PDF and use the send PDF to iPhoto option - this will give you the pages as images in iPhoto that you can them place into "book 3"
    See Old Toad's tutorial #19 for more details - http://web.mac.com/toad.hall/OldToadsTutorials/No._19.html - note that it is slightly different - you are only using the beginning part
    LN

  • Copy a page from one page group to another

    Hi
    Is it possible to copy a page from one page group to another?
    Regards,
    Lene

    Hi ,
    Through Portal it is not possible to copy a page from one page group to another .
    There is a feature in Portal WebDav .
    Through a DAV client you can copy page to your local system as a folder and then drag the page to the pagegroup you want to copy .
    Regards
    Medini

  • How to copy a folder from one document library to another document library ?

    How to copy a folder from one document library to another document library by programmtically?
    Samarendra Swain
    Team Sharepoint
    www.manuhsolutions.com

    You can use the SPFolder.CopyTo method.
    public static void CopyFolder()
    SPFolder folder = null;
    using (SPSite site = new SPSite("http://basesmcdev2/sites/tester1"))
    using (SPWeb web = site.OpenWeb())
    folder = web.GetFolder("shared%20documents/newfolder");
    folder.CopyTo("tester4/newfolder");
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.copyto.aspx
    certdev.com

  • How do I copy a page from one pdf  document to another?

    I am a newbe!

    That was easy.Thank you.
         Re: How do I copy a page from one pdf document to another?
    created by George Johnson in Creating, Editing & Exporting PDFs - View the full discussion
    If you open both documents, you can drag a page from the Pages panel (on the left of the window) of one document and drop it into the Pages panel of another.
    You can also extract one or more pages from a document to create a new document, and then insert the pages from this new document into another. In Acrobat 11 you 'd do this by doing:
    Tools > Pages > Extract
    and then:
    Tools > Pages > Insert from File
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6163925#6163925
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/6163925#6163925
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/6163925#6163925. In the Actions box on the right, click the Stop Email Notifications link .
    Start a new discussion in Creating, Editing & Exporting PDFs at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0 .

  • Concerning midi data in GarageBand for iOS: can we copy midi data from one virtual instrument to another?

    Concerning midi data in GarageBand for iOS: can we copy midi data from one virtual instrument to another?
    For instance: I play my "lucky take" on the virtual piano, and now I am curious how it would sound on let's say a organ. Normally I would select the midi content out of the piano track and copy it into the organ track. I cannot figure out how to do this in GarageBand for iOS. Is there anyone out there with a solution?
    Thanks!

    It is limited, how you can move regions between tracks. Basically, you can move between tracks with the same touch instrument.  See the help: http://help.apple.com/garageband/ipad/2.0/index.html#chsec12c15d
    Move a region
    Drag the region left or right to move it forward or back in time. Align the left edge of the region with the bar or beat on the ruler where you want it to start playing.
    Drag the region up or down to move it to another track with the same Touch Instrument. You can also drag regions between Keyboard and Sampler tracks, and between Audio Recorder and Guitar Amp tracks. Smart Drums regions cannot be dragged to another Smart Drums track.
    If you move a region so that it overlaps another region, the overlapped part of the “covered” region is deleted.
    Paste a region
    You can paste a region you have copied, or paste an audio file from an app that supports copying audio to the clipboard. GarageBand supports 44.1 kHz sample rate, 16-bit depth uncompressed audio files.
    You can paste copied regions to another track with the same Touch Instrument. You can also paste regions between Keyboard and Sampler tracks, and between Audio Recorder and Guitar Amp tracks. Smart Drums regions cannot be pasted to another Smart Drums track. Audio files copied from another app can be pasted to Audio Recorder or Guitar Amp tracks.
    Move the playhead to the point where you want the region to start.
    Tap the header of the track where you want to paste the region to select the track.
    Tap the track where you want to paste the region, then tap Paste.You can also tap an empty area of Tracks view, then tap Paste. In this case the region is pasted into the currently selected track.

  • When I copy and paste from one source material to another  within adobe reader, all the words are in one sentence. I have to take extra time to separate  the words using the space bar. Can this be fix?

    When I copy and paste from one source material to another  within adobe reader, all the words are in one sentence. I have to take extra time to separate  the words using the space bar. Can this be fix?

    Hi Bernie,
    Are you trying to copy and paste from a pdf to another pdf?
    Regards,
    Rave

  • Need to transfer more than 150 employees from one company code to another company code

    Dear Sir/Madam,
    I am new in SAP HCM . We need to transfer more than 150 employees from one company code to another company code due to some business requirement. Please suggest the process of transfer from one company code to another company code considering the other element like gratuity , leave entitlement, Bonus , Exgratia   etc.
    Your quick response will be highly appreciated.
    Thanks & regards,
    Babuna Ray
    Mob:- 9007295305
    [email protected]

    Dear,
    do not transfer employee from one company code to another issues are as under.
    1. Employees Form 16 you will get wrong value as per I Tax law because of company is having different PAN & TAN.
    2. Form 24 Q annual return data will not get properly/easily from SAP because of form 24 Q will run on Payroll area base/ company code base
    3. PF number is different for these 2 company codes then you are unable to submit annual return.
    4. If employee will get hike after the transfer case then system will post expenses period wise means if employee is having 2 different cost center related 2 different company codes posting will done as per this scenario is it accepted to Account Depatment? it is reflected in FICO through KSBB how can they manage expenditure which is related to previous month?
    Like this many points are there you have to study it and then suggest to your client.
    Regards
    Subhedar
    9158881202

  • Migrate/Copy Contract details from one company code to another

    Hi,
    We are planning to migrate/copy some contracts from  one company code to another.
    I've read a related post regarding this, but I would like to know more about the steps on how to do it and if it is possible also to copy the conracts' present contract numbers and other contract details  to the new company code.
    Thank you so much.

    Hi Rachelle,
    you can use BAPIs in RE-FX.
    1. BAPI_RE_CN_GET_DETAIL to read the contract data
    2. Change the data according to your requirements
         For example it may be necessary to change the adjustment parameters ..
    3. BAPI_RE_CN_CREATE to create the contracts in the new company code
    If you want to have the same contract number you would have to switch to external numbering in the new company code.
    Regards, Franz

  • How to scan data from one internal table to another

    Hi All,
    let me know how to scan all from one internal table to another internal table. Pls provide me the syntax and code.
    i am very thankful to you all in advance.
    Thanks & Regards,
    Nagarjuna.

    if u want to copy data from itab1 to itab2  then use
    itab2[] = itab1[].
    if u want to compare whether both itab1 and itab2 are same or not,use
    if itab1[] = itab2[].
    *--same
    else.
    *--not same
    endif.
    if u want to compare itabs based on primary key....
    loop at itab1.
    read table itab2 with key f1 = itab1-f1.
    if sy-subrc <> 0.
    *--not same....
    endif.
    endloop.
    if u want to copy only few lines(say from 1 to 3) of itab1 to itab2 then use...
    append lines of itab1 from 1 to 3 to itab2.
    if internal tables don't have same structure,
    say only fields f1 and f2 are common,then
    loop at itab1.
    itab2-f1 = itab1-f1.
    itab2-f2 = itab1-f2.
    append itab2.
    clear itab2.
    endloop.
    if there are many common fields then...
    loop at itab1.
    move-corresponding itab1 to itab2.
    append itab2.
    clear itab2.
    endloop.
    Please don't forget to reward points....!!!
    Regards
    vasu

Maybe you are looking for

  • Troubleshoot system errors or freezes in Photoshop Lightroom

    Issue: Lightroom 2.0, refuses to start, crashes, stalls, freezes, produces system errors, etc. Solution: There are a number of possible causes for above problems, which are too numerous to cover in the space provided. However, Adobe have provided a n

  • Blocked ALV Excel Download Issue

    Hi Experts, My customers requirement is to download the output of Quotation Comparison Report with exact alignments as how it displays on Screen. When I tried to download from Standard SAP Save options, like List->save.... Export.. Spreadsheet.......

  • Query Builder problem with saving to SQL text file

    When developing an SQL statement in Query Builder and saving it for later use, one has the option of saving in .SQL file extension. However, this file can not be used by the data wizard of Oracle*Reports because it contains non-ascii text. It appears

  • Setting width of a new document

    Evening all, I am trying to set up an AppleScript that opens a new document 100 pixels by 100 pixels. But when I try the code below, it opens a document 100 inches wide. How do I set the size to pixels? My code: make new document with properties {hei

  • Error in Asset Master Creation for Low Value assets

    Hi, I am trying to create an asset under the asset class Low value asset. while saving the asset the system delivers the following Error: 01 Book depreciation E614 Low value asset max.amount exceeded. No posting allowed 02 Special tax depreciation fo