Find the 'String' from excel sheet and save to another
sheet.But we don't know the string column number and row number?

Answers were Sorted based on User's Feedback



Find the 'String' from excel sheet and save to another sheet.But we don't know the s..

Answer / pushkar1206

This is working code. Don't forget to save workbook else nothing will get saved. Code is:

Set obj=createobject("excel.application")
Set obj2=obj.Workbooks.Open("C:UserspushkarDesktopBook1.xls")
Set obj3=obj2.Worksheets("Sheet1")
Set obj4=obj2.Worksheets("Sheet2")
rw=obj3.usedrange.rows.count
clm=obj3.usedrange.columns.count
For i=1 to rw
For j=1 to clm
a=obj3.cells(i,j).value
If strcomp(a,"nature")=0 Then
obj4.cells(1,2)=a
End If
Next
Next
obj2.Save
obj.Quit

Is This Answer Correct ?    1 Yes 0 No

Find the 'String' from excel sheet and save to another sheet.But we don't know the s..

Answer / kishan

set xlo=createObject("Excel.Application")
xlo.visible=True
set wbo=xlo.Workbooks.open("D:\QTP\TestData\abcdef.xls")
set wso=wbo.worksheets("Sheet1")

rcnt=wso.usedRange.rowcount
ccnt=wso.usedRange.columncount

for i=1 to rcnt
for j=1 to ccnt
str=wso.cells(i,j)
position=instr(1,str,"expected_string")
if position > 1
print "Required String is in
cell"&wso.cells(i,j)
xlo.worksheets("sheet2").cells
(1,1)="expected_string"
end if
next
next

Is This Answer Correct ?    0 Yes 0 No

Find the 'String' from excel sheet and save to another sheet.But we don't know the s..

Answer / bharathchandra maddhi

Option explicit
Dim exo, wbo, wso1, wso2, nor, noc, i, j, x, y
'Open a Excel file
Set exo=CreateObject("excel.application")
exo.Visible=true
Set wbo=exo.Workbooks.Open("C:\Bharath.xls")
Set wso1=wbo.Worksheets("sheet1")
Set wso2=wbo.Worksheets("sheet2")
nor=wso1.usedrange.rows.count
noc=wso1.usedrange.columns.count
'Varifying excel sheet strings
For i=1 to nor step 1
For j=1 to noc step 1
x=wso1.cells(i,j)
x=cstr(x)
If strcomp(x,"Bharath")=0 Then
wso2.cells(1,1)=x
End If
Next
Next
'Close excel s/w and Destroy the objects
exo.Quit
Set wso1=Nothing
Set wso2=Nothing
Set wbo=Nothing
Set exo=Nothing

Is This Answer Correct ?    1 Yes 2 No

Find the 'String' from excel sheet and save to another sheet.But we don't know the s..

Answer / raju

Set xl = CreateObject("Excel.Application")
set xlwbook = xl.Workbooks.Open(Excel Path)

Set xlWS = xlwbook.Worksheets(1)

Set k = xl.Worksheets(1).UsedRange.Find(Value to
Search)
On error resume next
k=k.value
If err.number>0 Then
msgbox "Pass"
else
Flag=0
If flag=0 Then
Status = "Pass"
StepDesc = "The Work Book has the
values "
Else
Status = "Pass"
StepDesc = "The Work Book Does not
has the values "
End If
End If

Set xlWS = Nothing
set xlwbook = Nothing
Set xl = Nothing

Please let me know if it's not working
raju.ippali@gmail.com

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More QTP Interview Questions

When to Insert transactions in QTP?

3 Answers   Siemens,


Can you import and export data from XLS and how?

4 Answers  


who is developed QTP ? is it from Mecury or HP

2 Answers  


we have one text box and one list box(list box appear in same page or another page) what ever the text enter in text box that must be displyed in list box as first one. for example if we enter 10 in text box that is the 1st item in list box . after that we enter 11 then 11 is the 1st item and 10 is 2nd item. the maximum limit of list box is 10 items. if we enter 11th item the 10th item is deleted and llth one is add as 1st one and 9th one goes to 10th position

3 Answers   Covansys,


hi this is srinivasa(from blr) i complited my B.tech(e.c.e) in 2007 im searching job in s/w testing but idont have freshers resume for s/w testing please send some s/w testing resume for me(fresfers resumes only) advns thnks you

2 Answers  






I have the following Doubts Please clarify me with examples? 1.Could QTP cover entire application? or part of the application? 2.Shall we rewrite(modify) the Manual testcase to automate? 3.How can I execute my scripts through client mechine which is not having QTP installation 4.Few objects are not being identified by QTP afeter one month. what could be the reason for this (I am using trail version of 15 days)

2 Answers   Livetek,


What are the check points can be inserted without recording?

0 Answers  


How to do the scripting. Is there any inbuilt functions in qtp as in qtp-s. What is the difference between them? How to handle script issues?

0 Answers  


How the objecs properties are identified?Tell me in Hierarchical order?

5 Answers   IBM,


what is smart identification?

7 Answers  


Please have a look at this: a = Browser("Travel Boutique Online").Page("Travel Boutique Online_2").webelement("innerhtml:=2622").getroproperty("y") a=a+9 msgbox a Browser("Travel Boutique Online").Page("Travel Boutique Online_2").image("alt:=check","y:=a").click Now please let me explain. As clear from code I am trying to enter value of variable 'a' as Property y. But each time QTP AND MY SYSTEM stops responding when this line is execcuted. But When i enter some number in place of 'a' in the last line. it works fine. Please let me know what I am doing wrong at time of entering the variable in last line. Thanks a lot

3 Answers  


Diff between WEB APPLICATION AND CLIENT-SERVER APPLICATION?

2 Answers  


Categories