Results 1 to 5 of 5

Thread: Count number of rows in excel sheet

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Answers
    8

    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


  2. #2
    Junior Member
    Join Date
    Apr 2008
    Answers
    2

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


  3. #3

    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?


  4. #4
    Junior Member
    Join Date
    Dec 2007
    Answers
    13

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


  5. #5
    Contributing Member
    Join Date
    Oct 2007
    Answers
    30

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact