Tuesday

QTP- FInd duplicate value in excel

See if it works for you !


Call excel_Error_Search("C:\Tests\error.xls","invalid credentials")

function excel_Error_Search(filepath,strtofind)

Set objExl = CreateObject("Excel.Application")
objExl.visible=true
Set objWorkBook = objExl.Workbooks.Open(filepath)
Set objSheet = objExl.Sheets("Sheet1")

'strtofind="duplicate_val"
With objSheet.UsedRange
Set str = .Find (strtofind)
For each str in objSheet.UsedRange

If str=strtofind then’ compare with the expected data
'msgBox duplicate found

Reporter.reportevent 1,"Passed",strtofind

End If
Set str = .FindNext(str )
next
End With
objWorkBook.save
objWorkBook.close
set objExl=nothing

End Function

No comments:

Post a Comment