Jump to content
Sign in to follow this  
jrahman

Counting number of rows having data in Excel sheet

Recommended Posts

jrahman

I have an AUtoIT3 script which reads 10 cells of data in column 2 from an Excel sheet and put in a Array.

The code is as below:

;Read the data start from row 2, column 2, 10 cells downward direction and save in an array
Local $aArray1 = _ExcelReadArray($oExcel, 2, 2, 10, 1)

If the sheet is populated with more or less data, I have to change the number of cells (in the above case it is 10) in the script.

Is there any AutoIT3 function to count the number of rows in Excel those have data before putting them into the Array, in that case, I could replace cell number parameter '10' by a variable (as below):

Local $aArray1 = _ExcelReadArray($oExcel, 2, 2, $cellCount, 1)

Share this post


Link to post
Share on other sites
JohnOne

I don't use excel, but it does not appear there is a function for what you want in the Standard UDF.

It is just one of those functions you have to write, yourself, probably using _ExcelReadCell()


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
jdelaney

google VBA Excel usedcells:

ActiveSheet.UsedRange.Cells.Count

ActiveSheet.UsedRange.Rows.Count

ActiveSheet.UsedRange.Columns.Count

simple example:

Dim $atest[5]=[123,1234,12345,123456,123567]
$oExcel = _ExcelBookNew ()
_ExcelWriteArray ( $oExcel, 1, 1,$atest, 1  )
MsgBox ( 4096, "count rows", $oExcel.ActiveSheet.UsedRange.Rows.Count )
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
Spiff59

_ExcelReadSheetToArray() ought to work for you.

There's a version that is drastically faster than the production version here:

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.