Hi,
''assuming ur Column like this
''EmpName | EmpID | Salary"
Call Fn_PrintEmpDetials("5000")
Function Fn_PrintEmpDetials(empSal)
Dim objExcel,objWorkBook
Dim objvalueFind,sAddress,aRowCol,usedRowCount
Set objExcel = CreateObject("Excel.Application")
objExcel.visible=False
objExcel.AlertBeforeOverwriting=False
objExcel.DisplayAlerts=False
Set objWorkBook = objExcel.Workbooks.Open ("c:\ExcelFile.xls")
Set Cells=objSheet.Cells
Set objvalueFind=objSheet.UsedRange.Find("EmpName")
If Not objvalueFind is Nothing Then
sAddress=objvalueFind.Address
aRowCol=Split(sAddress,"$",-1,1)
'now u have column name EmpName
empNameColumn=aRowCol(2)
empNameRow=aRowCol(1)
End If
Set objvalueFind=objSheet.UsedRange.Find("Salary")
If Not objvalueFind is Nothing Then
sAddress=objvalueFind.Address
aRowCol=Split(sAddress,"$",-1,1)
'now u have column name of salary
salaryColumn=aRowCol(2)
salaryRow=aRowCol(1)
For iRowIteration=1 to objSheet.UsedRange.Rows.Count
getSalary=Cells(aRowCol(2),aRowCol(1)).Value
If Cstr(getSalary)=Cstr(empSal)Then
'it will print name of employe which having 5000 salary
print Cells(empNameColumn,aRowCol(1)).Value
'it will print salary of employe which having 5000 salary
print Cells(salaryColumn,aRowCol(1)).Value
End If
Next
End If
objExcel.ActiveWorkbook.Save
objExcel.Workbooks(1).Close
objExcel.Quit
Set objSheet=Nothing
Set objExcel=Nothing
End Function
--
Note: few Variable declaration are missing please check It will work fine
let me know u have further any query
:)
Thanks & Regards
Sujit
On Sat, Apr 21, 2012 at 7:40 PM, vijay kanaparthi <
[email protected]> wrote:
> Hi Frnz..
>
> Q-I have an excel file which have the columns like Emp_Name,Emp_id,
> Emp_Salary.
>
> how i will get all the details of the employee who is having salary
> 5000.Through QTP only..
>
>
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en