DigDeep Posted July 19, 2016 Share Posted July 19, 2016 (edited) I would need some help in getting the below tasks. 1. I am not sure how many rows might be in the column B. Could be 8 or 100 2. Read the Cell Vaue (in text format) from B2:Till End of the column B to look for the word "TRUE". 3. If any cell shows the word "TRUE", it should delete the complete row 4. If any cell shows the word "FALSE", it should leave it until the loop reaches end of the column B. Please help. Local $sRange5 = "B2:B23" Local $sResult = _Excel_RangeRead($oWorkbook, Default, $sRange5, 3) While 1 If $sResult = "FALSE" Then MsgBox(0, "", $sResult) ElseIf $sResult = "TRUE" Then _Excel_RangeDelete($oWorkbook.Worksheets(1), "2:2") EndIf If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ ContinueLoop WEnd Edited July 19, 2016 by DigDeep Link to comment Share on other sites More sharing options...
l3ill Posted July 19, 2016 Share Posted July 19, 2016 A For Next Loop would work better for this particular issue. aka check each cell one at a time and; continue loop/return/exit/delete row etc... depending on what is found. My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
water Posted July 19, 2016 Share Posted July 19, 2016 Check the wiki for how to get the last used cell. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
xcaliber13 Posted July 20, 2016 Share Posted July 20, 2016 (edited) Thought I would but a working script for this issue out here. Hope no one minds #include <Excel.au3> #include <ExcelConstants.au3> Const $sType = $xlCSVMSDOS Global $oExcel = _Excel_Open() Global $sTextFile = "PathtoFolder\temp.csv" Global $oWorkBook = _Excel_BookOpenText($oExcel, $sTextFile, Default) Global $iLastRow = $oWorkBook.ActiveSheet.UsedRange.Rows.Count Global $sString = "String to search for" For $i = $iLastRow To 1 Step -1 If _Excel_RangeRead($oWorkbook, Default, "C" & $i) = $sString Then $oExcel.Rows($i).Delete EndIf Next _Excel_BookSaveAs($oWorkbook, "PathtoFolder\temp.csv", $xlCSVMSDOS, True) $oWorkbook.Close _Excel_Close($oExcel) Tested and working with Excel 2013 All of the above was learned by water pointing me in the right direction. Again a big thank you to water for all the help he gives everyone. Edited July 21, 2016 by xcaliber13 Link to comment Share on other sites More sharing options...
water Posted July 20, 2016 Share Posted July 20, 2016 Please remove line Local $oExcel = ObjCreate("Excel.Application") This is done by _Excel_Open. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - 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