noellarkin Posted March 27, 2022 Share Posted March 27, 2022 _Excel_RangeRead($ExcelWorkBook, $Sheet, "A1:A3", 1) I'm aware of how to use sheet ranges to delimit Range Read. In the help file, I've also come across this: _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2) How can I edit _Excel_RangeRead($ExcelWorkBook, $sheet, "A1:A3", 1) so it reads all cells of column A (similar to the help file example) but without using the workbook.activesheet.usedrange object oriented format/syntax? Link to comment Share on other sites More sharing options...
Danp2 Posted March 27, 2022 Share Posted March 27, 2022 Why not use the recommended solution of workbook.activesheet.usedrange? ThomasBennett 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
noellarkin Posted March 27, 2022 Author Share Posted March 27, 2022 I'm iterating through sheets using a For/Next loop, so I need the sheet to be a variable, as in: Local $Sheet = "" Local $Array For i = 0 To UBound($SheetList) - 1 $Sheet = $SheetList[$i] $Array = _Excel_RangeRead($ExcelWorkBook, $Sheet, "A1:A3", 1) _ArrayDisplay($Array) Next Link to comment Share on other sites More sharing options...
Danp2 Posted March 27, 2022 Share Posted March 27, 2022 Have you tried like this? Local $Sheet = "" Local $Array For i = 0 To UBound($SheetList) - 1 $Sheet = $SheetList[$i] $Array = _Excel_RangeRead($ExcelWorkBook, $Sheet, $Sheet.Usedrange.Columns("A:A"), 1) _ArrayDisplay($Array) Next noellarkin 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
noellarkin Posted March 27, 2022 Author Share Posted March 27, 2022 Thanks, I tried it, but I'm getting the error: Error: Variable must be of type "Object". Link to comment Share on other sites More sharing options...
noellarkin Posted March 27, 2022 Author Share Posted March 27, 2022 I tried this, too, but the script just stalls when I run it: _Excel_RangeRead($ExcelWorkBook, $Sheet, "A:A", 1) Link to comment Share on other sites More sharing options...
Danp2 Posted March 27, 2022 Share Posted March 27, 2022 Where does $SheetList come from? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
noellarkin Posted March 27, 2022 Author Share Posted March 27, 2022 Sheet list is a 1D array of some of the sheets in the workbook that I'm iterating through in the function. Something like: Local $SheetList[4] = ["INFO", "CHECKLIST", "NAMELIST", "EMAILS"] where INFO, CHECKLIST, NAMELIST, EMAILS are sheets in the xlsx file. Link to comment Share on other sites More sharing options...
Danp2 Posted March 27, 2022 Share Posted March 27, 2022 (edited) Ok... Then something like this should work -- $Array = _Excel_RangeRead($ExcelWorkBook, $Sheet, $ExcelWorkBook.worksheets($Sheet).Usedrange.Columns("A:A"), 1) Edited March 27, 2022 by Danp2 Missing $ noellarkin 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Solution water Posted March 27, 2022 Solution Share Posted March 27, 2022 A $ is missing, should be: $Array = _Excel_RangeRead($ExcelWorkBook, $Sheet, $ExcelWorkBook.Worksheets($Sheet).Usedrange.Columns("A:A"), 1) noellarkin and Danp2 1 1 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...
noellarkin Posted March 28, 2022 Author Share Posted March 28, 2022 Thanks. This works. Link to comment Share on other sites More sharing options...
ThomasBennett Posted June 23, 2023 Share Posted June 23, 2023 On 3/27/2022 at 10:12 AM, Danp2 said: Why not use the recommended solution of workbook.activesheet.usedrange? ...not meaning to resurrect an old post; mod please have mercy. Look at _Excel_RangeRead Example 3:https://www.autoitscript.com/autoit3/docs/libfunctions/_Excel_RangeRead.htm Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 23, 2023 Moderators Share Posted June 23, 2023 (edited) 55 minutes ago, ThomasBennett said: ...not meaning to resurrect an old post And yet that is exactly what you did, a year after the OP accepted the resolution from the guy who wrote the example you're pointing him to. Edited June 23, 2023 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts