I am trying to delete specific rows in excel using applescript. I want to delete the rows based on a value in a given column. Within the given column, I have a list of values (ex. 3001, 3004, 5003, ect.) that I want to keep.
For instance, if any of my values (3001, 3004, 5003) are in column C I want to keep the row that contains that value. If the row doesn't contain one of my values in column C I want to delete that row. I found this applescript on here but all it does is delete everything but row 2 I can't get it to keep my range of values.
I substituted field 10 for field 3 since I was working with column C and I changed "(Not NY State)" to "(Not 3001)" but that didn't work. Also how do I need to list the values, do I list them as "(3001, 3004, 5003)" or "(3001; 3004; 5003) or what?
tell application "Microsoft Excel"
set autofilter mode of active sheet to false
set lastRow to first row index of last row of used range
autofilter range row ("1:" & lastRow) field 10 criteria1 "(Not NY State)"
select row ("2:" & lastRow)
delete selection -- if you want to delete
#clear contents selection -- if you only wish to clear the data
end tell