Jump to content
Sign in to follow this  
wutangah

Counting Excel Rows

Recommended Posts

wutangah

How do I count rows in Excel?

CODE
Func 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 $bColumnB

EndFunc

Share this post


Link to post
Share on other sites
weaponx

Look at you Mr. Fancy Font.

_ExcelSheetUsedRangeGet is the correct function, is it not working?

Share this post


Link to post
Share on other sites
wutangah

>>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

Share this post


Link to post
Share on other sites
PsaltyDS

>>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

Share this post


Link to post
Share on other sites
wutangah

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 column

Is my comprehension correct?

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
wutangah

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.