Option explicit
Dim oex, owb, nr, ows, a, b, eop, qop, i
'open excel sw
Set oex=createobject("Excel.Application")
oex.Visible=true 'set excel as visible
'open excel wb
set owb=oex.Workbooks.Open("F:\Book1.xls")
'open excel worksheet
Set ows=owb.Worksheets("Sheet2")
'count no of rows
nr=ows.usedrange.rows.count 'count no of rows to be added
For i=2 to nr step 1
a=ows.cells(i,1) 'get first input
a=cint(a)
b=ows.cells(i,2) 'get second input
b=cint(b)
eop=ows.cells(i,3) 'get value from excel
qop=a+b 'add two inputs by using qtp
print(qop)
ows.cells(i,4)=qop 'store the ouput in qtp
'check correct ness of addition
If eop=qop Then
ows.cells(i,5)="Correct Value"
Else
ows.cells(i,5)="Incorrect Value"
End If
Next
'save and close excel file
owb.Save
oex.Quit
'destroy object by de allocating the memory
Set ows=nothing
Set owb=nothing
Set oex=nothing
Dim oex, owb, nr, ows, a, b, eop, qop, i
'open excel sw
Set oex=createobject("Excel.Application")
oex.Visible=true 'set excel as visible
'open excel wb
set owb=oex.Workbooks.Open("F:\Book1.xls")
'open excel worksheet
Set ows=owb.Worksheets("Sheet2")
'count no of rows
nr=ows.usedrange.rows.count 'count no of rows to be added
For i=2 to nr step 1
a=ows.cells(i,1) 'get first input
a=cint(a)
b=ows.cells(i,2) 'get second input
b=cint(b)
eop=ows.cells(i,3) 'get value from excel
qop=a+b 'add two inputs by using qtp
print(qop)
ows.cells(i,4)=qop 'store the ouput in qtp
'check correct ness of addition
If eop=qop Then
ows.cells(i,5)="Correct Value"
Else
ows.cells(i,5)="Incorrect Value"
End If
Next
'save and close excel file
owb.Save
oex.Quit
'destroy object by de allocating the memory
Set ows=nothing
Set owb=nothing
Set oex=nothing
No comments:
Post a Comment