18 Dec 2012

Excel Scripts


Print diagonal values in an execl sheet

set exec_app=createobject("excel.application")

set MyFile=exec_app.workbooks.open("D:\Book1")

Set my_sheet=MyFile.sheets("Sheet3")

my_sheet.activate

iRow=my_sheet.usedrange.rows.count

msgbox iRow

For i=1 to iRow

x=my_sheet.cells(i,i).value

temp=temp+x

Next

msgbox temp

exec_app.Quit

Print the sum of numbers in the execl sheet


set exec_app=createobject("excel.application")

set MyFile=exec_app.workbooks.open("D:\Book1")

Set my_sheet=MyFile.sheets("Sheet3")

my_sheet.activate

iRow=my_sheet.usedrange.rows.count

iCol=my_sheet.usedrange.columns.count

For i=1 to iRow

For j=1 to iCol

x=my_sheet.cells(i,j).value

'msgbox x

temp=temp+x

next

next

msgbox temp

exec_app.Quit

No comments:

Post a Comment