kawumm3000 1 Posted March 12, 2021 Share Posted March 12, 2021 Hi, as the title says, I want to use _Excel_RangeFind in a specific sheet. How can I choose the sheet here? Thx Link to post Share on other sites
Nine 1,501 Posted March 12, 2021 Share Posted March 12, 2021 The third param specify the range. Something like this : #include <Excel.au3> Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, @MyDocumentsDir & "\Test.xls") Local $aResult = _Excel_RangeFind($oWorkbook, "Test", $oWorkbook.sheets(2).usedRange) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "RangeFind Error", @error & "/" & @extended) _ArrayDisplay($aResult) FrancescoDiMuro 1 Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search content in 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 GIF Animation (cached) Screen Scraping Link to post Share on other sites
FrancescoDiMuro 463 Posted March 12, 2021 Share Posted March 12, 2021 (edited) @kawumm3000 You could use Worksheets collection to search in a specific sheet: #include <Array.au3> #include <Excel.au3> Test() Func Test() Local $strFileName = @ScriptDir & "\Test.xlsx", _ $objExcel, _ $objWorkbook, _ $arrResult $objExcel = _Excel_Open() If @error Then Return ConsoleWrite("_Excel_Open ERR: " & @error & @CRLF) $objWorkbook = _Excel_BookOpen($objExcel, $strFileName) If @error Then Return ConsoleWrite("_Excel_BookOpen ERR: " & @error & @CRLF) ; Use $objWorkbook.Worksheets(SheetNumber).UsedRange or $objWorkbook.Worksheets(SheetName).UsedRange $arrResult = _Excel_RangeFind($objWorkbook, "TextToFind", $objWorkbook.Worksheets(1).UsedRange) If @error Then Return ConsoleWrite("_Excel_RangeFind ERR: " & @error & @CRLF) If UBound($arrResult) > 0 Then _ArrayDisplay($arrResult) _Excel_BookClose($objWorkbook) _Excel_Close($objExcel) EndFunc @Nine Edited March 12, 2021 by FrancescoDiMuro Nine 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to post Share on other sites
Nine 1,501 Posted March 12, 2021 Share Posted March 12, 2021 Great minds think alike FrancescoDiMuro 1 Not much of a signature but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search content in 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 GIF Animation (cached) Screen Scraping Link to post Share on other sites
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