wutangah Posted August 23, 2007 Share Posted August 23, 2007 How do I count rows in Excel?CODEFunc load_array()$aColumnA = 0 $bColumnB = 0 $sheet_num = _ExcelSheetNameGet($oExcel) MsgBox(0, "Report Value of $sheet_num", $sheet_num) $cell_num = _ExcelSheetUsedRangeGet($oExcel, $sheet_num) ;Is this the right function to use? MsgBox(0, "Report Value of $cell_num", $cell_num) $aColumnA = _ExcelReadArray($oExcel, 1, 1, 0+$cell_num, 1, 0) ;Dump Column A to array $aColumnA $bColumnB = _ExcelReadArray($oExcel, 1, 2, 0+$cell_num, 1, 0) ;Dump Column B to array $bColumnBEndFunc Link to comment Share on other sites More sharing options...
weaponx Posted August 23, 2007 Share Posted August 23, 2007 Look at you Mr. Fancy Font. _ExcelSheetUsedRangeGet is the correct function, is it not working? Link to comment Share on other sites More sharing options...
wutangah Posted August 23, 2007 Author Share Posted August 23, 2007 >>Look at you Mr. Fancy Font. I have style. >>_ExcelSheetUsedRangeGet is the correct function, is it not working? It is not working. Here is the error CODE==> Array variable subscript badly formatted.: Local $aArray[$iNumCells + $iIndexBase] Local $aArray[^ ERROR Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 23, 2007 Share Posted August 23, 2007 >>Look at you Mr. Fancy Font. I have style. >>_ExcelSheetUsedRangeGet is the correct function, is it not working? It is not working. Here is the error CODE==> Array variable subscript badly formatted.: Local $aArray[$iNumCells + $iIndexBase] Local $aArray[^ ERROR That function returns an array. You can't display it in MsgBox(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
wutangah Posted August 23, 2007 Author Share Posted August 23, 2007 That function returns an array. You can't display it in MsgBox(). Thanks for the insight.Here is my understanding so far:_ExcelReadArray needs a value to read the column_ExcelSheetUsedRangeGet gets anything in the columnIs my comprehension correct? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 23, 2007 Share Posted August 23, 2007 Thanks for the insight. Here is my understanding so far: _ExcelReadArray needs a value to read the column _ExcelSheetUsedRangeGet gets anything in the column Is my comprehension correct? I don't think so. The function _ExcelSheetUsedRangeGet returns an array of values representing the extent of used rows/columns in the sheet. Quoting the function header: ;=============================================================================== ; ; Description: Return the last cell of the used range in the specified worksheet. ; Syntax: $array = _ExcelSheetUsedRangeGet($oExcel, $vSheet) ; Parameter(s): $oExcel - An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew() ; $vSheet - The sheet name or number to be checked. ; Requirement(s): None ; Return Value(s): On Success - Returns an array of used range values: ; $array[0] - The last cell used, in A1 format (if 0 is returned, worksheet is blank) ; $array[1] - The last cell used, in R1C1 format ; $array[2] - The last column used, as an integer ; $array[3] - The last row used, as an integer ; On Failure - Returns 0 (as non-array numeric value) and sets @error on errors: ; @error=1 - Specified object does not exist ; @error=2 - Invalid sheet number ; @error=3 - Invalid sheet name ; Author(s): DaLiMan, SEO <locodarwin at yahoo dot com> ; Note(s): Upon return, $array[0] will equal numeric value 0 if the worksheet is blank ; ;=============================================================================== So in your code from the OP, the row count is in $cell_num[3]. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
wutangah Posted August 28, 2007 Author Share Posted August 28, 2007 I don't think so. The function _ExcelSheetUsedRangeGet returns an array of values representing the extent of used rows/columns in the sheet. Quoting the function header: So in your code from the OP, the row count is in $cell_num[3]. Thanks! 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