(2017-10-18 22:57:52)
分類:
辦公做個簡單示例,在程序的同一目錄下做個 Book1.xls 并放些數(shù)據(jù) ,示例的功能是 把A,B,D列的第1行到100行的數(shù)據(jù)匯總在 第101行 ,你測試一下。
Private Sub Command1_Click()
Set oExcel = CreateObject("Excel.Application") 'excel對象
Set oFun = oExcel.WorksheetFunction 'excel宏函數(shù) 對象
Set oWk = oExcel.Workbooks.Open(App.Path & "\Book1.xls") '工作簿 對象,完整路徑
With oWk.Sheets("Sheet1")
.Range("a101") = oFun.Sum(.Range("a1:a100"))
.Range("b101") = oFun.Sum(.Range("b1:b100"))
.Range("d101") = oFun.Sum(.Range("d1:d100"))
End With
oWk.Close True
Set oWk = Nothing
Set oFun = Nothing
Set oExcel = Nothing
End Sub
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。