xcaliber13 Posted September 29, 2016 Share Posted September 29, 2016 Does anyone know what I would do for this: I have an excel spreadsheet that I want to delete the entire row if text = "xyz" in column D For $i = 1 To $cLastRow $sCell = _Excel_RangeRead($oWorkBook, Default, "D" & $i) If $sCell = "xyz" Then _Excel_RangeDelete($oWorkBook.Activesheet, "D" & $i, $xlShiftToLeft, Default) Next I am not having an issue with this function, works great But that only works if that is the only text in the cell. How would I do this if the cell contains: some text xyz some more text ?? So the cell contains other text other than just xyz. Any help pointing me in the correct direction would be great. Thank you Link to comment Share on other sites More sharing options...
water Posted September 29, 2016 Share Posted September 29, 2016 (edited) Use If $sCell = "xyz" Then _Excel_RangeDelete($oWorkBook.Activesheet, $oWorkBook.Activesheet.Range("D" & $i).EntireRow, $xlShiftToLeft, Default) as described here: https://www.autoitscript.com/wiki/Excel_Range#Entire_Row_.2F_Entire_Column Edited September 29, 2016 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
xcaliber13 Posted September 29, 2016 Author Share Posted September 29, 2016 Water, Sorry I did not explain correctly. What I want to do is delete the cell that contains text xyz plus other text and then shift to the left. The above code works to do that if the cell only contains "xyz" . How to get this to work if the cell contains more text than just "xyz"? So the code I posted works if the cell only contains the text "xyz". What I can't figure out is how to get this to work if the cell contains more text than just "xyz" Thank you Link to comment Share on other sites More sharing options...
water Posted September 29, 2016 Share Posted September 29, 2016 Ah, I see. In this case use _Excel_RangeFind to get an array of cells in the range which contain "xyz". Then process the array from the last to the first row so you do not delete the wrong rows in Excel. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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