kctvt Posted May 27, 2022 Posted May 27, 2022 Hi there, I have a file Book1.xlsx . I want to read infomation in A3,B3,C3,D3,E3,F3..... etc ..... P3. And I want to use While to read that. How A change into P3 when we use While ? In my full file, I have to read A3 --> EXL3 (4017 coulmn). Book1.xlsx
water Posted May 27, 2022 Posted May 27, 2022 Simply set parameter $vRange to "A3:EXL4017" 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
Subz Posted May 27, 2022 Posted May 27, 2022 Unsure if you meant you want to read specific columns within a While loop, if so you can always use _Excel_ColumnToNumber, example: #include <Array.au3> #include <Excel.au3> ;~ Excel Column/Row Start Local $sCol1 = "A" Local $iCol1 = _Excel_ColumnToNumber($sCol1) Local $iRow1 = 3 ;~ Excel Column/Row End Local $sCol2 = "P" Local $iCol2 = _Excel_ColumnToNumber($sCol2) Local $iRow2 = 3 Local $oExcel = _Excel_Open() If @error Then Exit MsgBox(16, "Error", "Unable to open Excel") Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Example.xlsx") If @error Then Exit MsgBox(16, "Error", "Unable to open workbook") Local $aRange = _Excel_RangeRead($oWorkbook, Default, $sCol1 & $iRow1 & ":" & $sCol2 & $iCol2) ;~ Read Column P ConsoleWrite("Value of Column P3 : " & $aRange[0][$iCol2 - 1] & @CRLF & @CRLF) ;~ Read Columns A to P For $i = ($iCol1 - 1) To ($iCol2 - 1) ConsoleWrite(_Excel_ColumnToLetter($i + 1) & $iRow1 & " = " & $aRange[0][$i] & @CRLF) Next
water Posted May 27, 2022 Posted May 27, 2022 Performancewise reading cell by cell isn't the fastest solution. Read Row by Row to an array and then process the array. Or read the whole content (by using UsedRange) in one go. 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
Subz Posted May 27, 2022 Posted May 27, 2022 Little confused, the script above is reading the entire row into an array and then looping through the array to show each of the results? Not sure if that's what the OP was referring to though, it sounded like he wanted to loop through the results.
water Posted May 27, 2022 Posted May 27, 2022 I will wait until the OP tells us exactly why he want's to process the Workbook in the way he described. When we know what he wants to achieve we might propose a better solution 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
kctvt Posted June 1, 2022 Author Posted June 1, 2022 Thank you everybody, I used _Excel_ColumnToLetter() . It worked.
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