aa2zz6 Posted June 29, 2021 Share Posted June 29, 2021 (edited) How do I check whether a certain cell or multiple cells are blank? The goal is to loop each excel sheet without having to open , check if a cell W57 is blank , and if it's blank do nothing, else move to another directory #include <File.au3> $FileList = _FileListToArray("Z:\Shared\Enterprise File Shares\NEO Assignments\Strasburg Assignments\New Assignments") If @error = 1 Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf For $i = 1 To $FileList[0] MsgBox(0, $i, $FileList[$i]) Next Edited June 29, 2021 by aa2zz6 Link to comment Share on other sites More sharing options...
Solution Nine Posted June 29, 2021 Solution Share Posted June 29, 2021 Try this : #include <Excel.au3> #include <File.au3> Local $aFile = _FileListToArrayRec(@ScriptDir, "*.xls;*.xlsx", $FLTA_FILES, Default, Default, $FLTAR_FULLPATH) If @error Then Exit ;_ArrayDisplay($aFile) Local $oExcel = _Excel_Open(False) Local $oWB, $sW57 For $i = 1 To $aFile[0] $oWB = _Excel_BookOpen($oExcel, $aFile[$i]) $sW57 = _Excel_RangeRead($oWB, Default, "W57") If StringStripWS($sW57, $STR_STRIPLEADING+$STR_STRIPTRAILING) <> "" Then ConsoleWrite($aFile[$i] & @CRLF) EndIf _Excel_BookClose($oWB) Next _Excel_Close($oExcel) aa2zz6 and robertocm 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
aa2zz6 Posted July 9, 2021 Author Share Posted July 9, 2021 @Nine This is perfect! Thank you sir Link to comment Share on other sites More sharing options...
aa2zz6 Posted July 13, 2021 Author Share Posted July 13, 2021 How do I get my script to loop through an array variable $OfficeSearch? #include <Excel.au3> #include <File.au3> Global $strasburg_Office = @ScriptDir & "\..\../2) Strasburg Office/0_Service_Request/" Global $OfficeSearch[3] = ["Strasburg", "Lancaster", "Mentor"] Global $aFile = _FileListToArrayRec(@ScriptDir, "*.xls;*.xlsx", $FLTA_FILES, Default, Default, $FLTAR_FULLPATH) If @error Then Exit ;_ArrayDisplay($aFile) Global $oExcel = _Excel_Open(False) Global $oWB, $sW57 For $i = 1 To $aFile[0] $oWB = _Excel_BookOpen($oExcel, $aFile[$i]) $sW57 = _Excel_RangeRead($oWB, Default, "AA3") For $i = 1 To $OfficeSearch[0] If StringStripWS($sW57, $STR_STRIPLEADING+$STR_STRIPTRAILING) == "'Mentor" Then ConsoleWrite($aFile[$i] & @CRLF) Global $sFilName = StringRegExpReplace($aFile[$i], "^.*\\|\..*$", "") ;MsgBox(0,"msgbox", $sFilName , 5000) FileMove($aFile[$i], $strasburg_Office & $sFilName & ".xls", $FC_NOOVERWRITE) EndIf Next _Excel_BookClose($oWB) Next _Excel_Close($oExcel) Link to comment Share on other sites More sharing options...
Nine Posted July 13, 2021 Share Posted July 13, 2021 3 minutes ago, aa2zz6 said: How do I get my script to loop through an array variable $OfficeSearch? What do you mean by that ? I do not understand what you want to achieve with this... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
water Posted July 13, 2021 Share Posted July 13, 2021 (edited) Change For $i = 1 To $OfficeSearch[0] to For $i = 0 To Ubound($OfficeSearch) - 1 This is needed because your array does not hold the number of array elements in element 0. Edited July 13, 2021 by water Fixed the bug as described by Nine in the following post. 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...
Nine Posted July 13, 2021 Share Posted July 13, 2021 @water probably meant : For $i = 0 To Ubound($OfficeSearch) - 1 And there is a single quote before Mentor which shouldn't be there. But I would still like to understand what is the end goal of your previous code... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
aa2zz6 Posted July 13, 2021 Author Share Posted July 13, 2021 11 minutes ago, Nine said: @water probably meant : For $i = 0 To Ubound($OfficeSearch) - 1 And there is a single quote before Mentor which shouldn't be there. But I would still like to understand what is the end goal of your previous code... Hey Nine, I'm trying to setup a file Manager script so that when excel sheets (See images) get created by our customer service reps in the New Assignments folder the File Manager script reads cell AA3 determines which office (Strasburg, Lancaster, Mentor) and moves it to the office folder. What would be the best practice because I'm thinking duplication might be an issue possibly? Link to comment Share on other sites More sharing options...
Nine Posted July 13, 2021 Share Posted July 13, 2021 Ok if I understand correctly. Based on AA3 you want to move the Excel file to one of the office locations. Try this (untested): #include <Excel.au3> #include <File.au3> Global $OfficeDir[3] = ["Full\path\to\Strasburg\", "Full\path\to\Lancaster\", "Full\path\to\Mentor\"] Global $OfficeSearch[3] = ["Strasburg", "Lancaster", "Mentor"] Global $aFile = _FileListToArrayRec(@ScriptDir, "*.xls;*.xlsx", $FLTA_FILES, Default, Default, $FLTAR_FULLPATH) If @error Then Exit _ArrayDisplay($aFile) Global $oExcel = _Excel_Open(False) Global $oWB, $sLocation, $sDrive, $sDir, $sFileName, $sExtension For $i = 1 To $aFile[0] $oWB = _Excel_BookOpen($oExcel, $aFile[$i]) $sLocation = StringStripWS(_Excel_RangeRead($oWB, Default, "AA3"), $STR_STRIPLEADING+$STR_STRIPTRAILING) For $j = 0 To UBound($OfficeSearch) - 1 If $sLocation = $OfficeSearch[$j] Then ConsoleWrite("Moving " & $aFile[$i] & " to " & $OfficeSearch[$j] & @CRLF) _PathSplit($aFile[$i], $sDrive, $sDir, $sFileName, $sExtension) FileMove($aFile[$i], $OfficeDir[$j] & $sFileName & $sExtension) ExitLoop EndIf Next If $j = UBound($OfficeSearch) Then ConsoleWrite("Error on " & $aFile[$i] & @CRLF) _Excel_BookClose($oWB) Next _Excel_Close($oExcel) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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