Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript - delete row's in excel

Hey guy's i would like to sort my information in excel with an applescript and then delete the row's contains the text "example"

i don't know if is necessary to sort i just want to delete the row's that contain "example" somebody can help me???

OS X Mountain Lion (10.8.5)

Posted on Jul 24, 2015 7:58 AM

Reply
Question marked as Best reply

Posted on Jul 24, 2015 6:18 PM

Here's one way:


User uploaded file


Result:


User uploaded file


SG



set searchStr to "example"

tell application "Microsoft Excel"

tell active workbook

tell worksheet "Sheet1"

tell used range


--loop from bottom, deleting when searchStr found

repeat with i from (count rows) to 1 by -1

set rowVals to row i's value

if searchStr is in rowVals's item 1 then delete row i

end repeat

end tell

end tell

end tell

end tell

4 replies
Question marked as Best reply

Jul 24, 2015 6:18 PM in response to L.Valdivia

Here's one way:


User uploaded file


Result:


User uploaded file


SG



set searchStr to "example"

tell application "Microsoft Excel"

tell active workbook

tell worksheet "Sheet1"

tell used range


--loop from bottom, deleting when searchStr found

repeat with i from (count rows) to 1 by -1

set rowVals to row i's value

if searchStr is in rowVals's item 1 then delete row i

end repeat

end tell

end tell

end tell

end tell

Aug 4, 2015 7:52 AM in response to SGIII

Dear, SGIII

i would like to know if you can help me with this little problem that i found in a new script that i working

i have to delete rows that no make this condition true.

first i have to insert the number of the month i need in this case for example is 6 so.. the condition is

repeat with i from (count rows) to 2 by -1

if value in column N=0 then

if value in column O=displaydialog

(do not delete)

else

if value in column N=displaydialog

(do not delete)

else

delete all the row

end if

end if


EXAMPLE:

User uploaded file

i try your script but not work for an specific column

tell active workbook

tell worksheet "Sheet1"

tell used range

repeat with i from (count rows) to 2 by -1

set rowVals to rowi'svalue

if searchStr is in rowVals's item 1 then delete row i

end if

end repeat

end tell

end tell

end tell


HELP ME PLEASE

Aug 4, 2015 8:45 AM in response to L.Valdivia

L.Valdivia wrote:


i try your script but not work for an specific column



I'm not sure what you need to do with your dialogs, etc., but the version of the script below will look in one column only (instead of the whole row) and, looping from the bottom, if it finds a match it will delete that row. Here it deletes rows with 0 in column N.


SG



set searchVal to 0

set searchCol to 14 --> column N

tell application "Microsoft Excel"

tell active workbook

tell worksheet "Sheet1"

tell used range

repeat with i from (count rows) to 2 by -1

set colVal to rowi'scellsearchCol'svalue

if searchVal is colVal then delete row i

end repeat

end tell

end tell

end tell

end tell

AppleScript - delete row's in excel

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.