Thursday, 8 May 2014

QTP - UFT - How to get used range in excel


                                          


Code:-
strFilePath = "C:\DelMelater\UserData.xlsx"
Set o1 = CreateObject("Excel.Application")
Set objworkbook = o1.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
o1.Quit
Set o1 = 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