-
Junior Member
Count number of rows in excel sheet
hi all,
can anybody tell me
i have an excel sheet in which i entered 50 rows of data..now i want to count the number of rows in the Excel sheet using QTP script..(without importing to global or local sheet).
can anybody help me in this..
thanks inadvance
chandu
-
Junior Member
Re: Count number of rows in excel sheet
Set objExcel = CreateObject("Excel.Application") ' Open the file
'objExcel.Application.Visible=true
objExcel.Workbooks.open ("") ' Select the worksheet
NOw you can use count method and extract the number of rows...
-
Moderator
Re: Count number of rows in excel sheet
Why do you want to count the number of rows since you already know that it has 50 rows of data?
-
Junior Member
Re: Count number of rows in excel sheet
static File_Path="";#Exact Path of the Excel file
static rc,T_R_C;
#----------------------------------------------------------------------------
#Action:Count the number of Rows in the Excel sheet
#----------------------------------------------------------------------------
rc=ddt_open(File_Path,DDT_MODE_READ);
if((rc!=E_OK) && (rc!=E_FILE_OPEN))
{
treturn("File Not Open");
}
ddt_get_row_count(File_Path,T_R_C);
printf("\t Number of Rows in the Table is :\t" T_R_C);
-
Contributing Member
Re: Count number of rows in excel sheet
Hi below function would return no of rows for a specific column name :
Public Function UdfExcelNoofRowforCol(Sheet, Row, Col,columnname)
' Get the position of the last row containing data.
LastRow = Sheet.Range(columnname&"65536").End(xlUp).Row
' Get the position of the last column containing data for the above row.
colrange = "IV" & LastRow ' This value may need to be modified to meet the needs of your excel file.
LastCol = Sheet.Range(colrange).End(xlToLeft ).Column
' Return the row and column values
Row = LastRow
Col = LastCol
End Function
Public Const xlDown = -4121
Public Const xlToLeft = -4159
Public Const xlToRight = -4161
Public Const xlUp = -4162
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules