Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Saturday 18 February 2017

How to get used range in excel

Code:-

strFilePath = "C:\UFT_Folder\UserData.xlsx"

Set Excel_Obj = CreateObject("Excel.Application")


Set objworkbook = Excel_Obj.Workbooks.Open(strFilePath)
Set objworksheet = objworkbook.Worksheets("Sheet1")

msgbox objworksheet.usedrange.rows.count
msgbox objworksheet.usedrange.columns.count
msgbox objworksheet.usedrange.Address

Set objworksheet = nothing
Set objworkbook = nothing

Excel_Obj.Quit


Set Excel_Obj = nothing

' The First message box will give you used Rows Count
' The First message box will give you used columns Count
' The First message box will give you address of the last cell used like $F$8:$G$10



No comments:

Post a Comment

Note: only a member of this blog may post a comment.