Jump to content
xcaliber13

Excel Delete Help

Recommended Posts

xcaliber13

Hi,

     I am trying to delete a cell in excel if  a cell contains a key word.   The cell also has other text.   I use this if the cell only contains a single word.

For $a = 1 To $aLastRow
    $aCell = _Excel_RangeRead($oWorkbook, Default, "K" & $a)
    If $aCell = "APT" Then _Excel_RangeInsert($oWorkBook.Activesheet, "K" & $a, $xlShiftToRight)
Next

So this works great but only if that cell only contains "APT".  How would I do this so that if the cell contains APT 1  or APT 2 and so on it would still do the delete?  In VBS there is a "like" command.   What is the syntax for like in  AutoIt?   I tried   $aCell.Value.like   but AutoIt does not like that.  Gives me a syntax error

Thank you

Edited by xcaliber13

Share this post


Link to post
Share on other sites
benners

how about

If StringInStr($aCell, 'APT') Then _Excel_RangeInsert($oWorkBook.Activesheet, "K" & $a, $xlShiftToRight)

obviously if the string is 'capt' it will match as well, depends on what other text maybe in the cells. 

Share this post


Link to post
Share on other sites
xcaliber13

benners,

             StringInStr!   What a brilliant idea!   Works like a charm.

Thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×