Showing posts with label Set. Show all posts
Showing posts with label Set. Show all posts

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


Saturday, 3 May 2014

QTP - UFT - Can you write a script to sort "uftquestions" as "efinoqssttuu"

One of the best method I would use for sorting is using object of "System.Collections.ArrayList"

Code:
Set o1 = Createobject("system.collections.ArrayList")
strInput = "UFTQuestions"
For k = 1 To len(strInput)
    o1.Add mid(strInput,k,1)
Next
o1.sort

For uj = 0 to o1.count-1
    strOutput = strOutput & o1(uj)
Next
msgbox strOutput

Output:- strOutput is "eFinoQsstTuU"

Happy reading,
Sreenu Babu