xcaliber13 Posted May 26, 2017 Share Posted May 26, 2017 (edited) 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 May 26, 2017 by xcaliber13 Link to comment Share on other sites More sharing options...
benners Posted May 26, 2017 Share Posted May 26, 2017 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. Link to comment Share on other sites More sharing options...
xcaliber13 Posted May 26, 2017 Author Share Posted May 26, 2017 benners, StringInStr! What a brilliant idea! Works like a charm. Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now