PDA

View Full Version : Applescript. Copy filtered cells in Excel




Palkan
Jul 2, 2012, 04:34 PM
I have a task for Applescript to filter Excel cells based on one criteria "NEW" in column "F" and then copy the filtered cells to a new spreadsheet (new file). I succeeded in filtering the data but now I can't figure out how to copy the result and paste it to the new Excel file. I can not manually define range because the filtered data will be different all the time, so I need automated way to identify the filtered range, select, copy and paste in into new CSV file. Thats what I have so far:

tell application "Microsoft Excel"
set myFile to "Macintosh HD:Users:JustDo:Desktop:AppleScript:Template.xlsx"
set new_book to open workbook workbook file name myFile
autofilter range range "A1:F1" field "6" criteria1 "NEW"
end tell

Thanks for your help



ender land
Jul 2, 2012, 09:08 PM
Is there a reason you want to use AppleScript instead of VBA?

Palkan
Jul 3, 2012, 10:34 AM
There is no big reason behind that. At this time I'm just trying to find the best way to perform the task and achieve the result. Maybe VBA would be better, but at this moment I have been playing with AppleScript, thats why I decided to check if it would do that. Ultimately, VBA would work.

Thanks