在VB中如何使用EXCEL函数

解决方案 »

  1.   

    在VB中使用Excel中的sum函数来计算A1和B1单元格之和Private Sub Command2_Click()
        Dim xlApp As New Excel.Application
        Dim xlBook  As Excel.Workbook
        Dim xlSheet As Excel.Worksheet
        
        xlApp.Caption = "test"
        Set xlBook = xlApp.Workbooks.Add
        Set xlSheet = xlBook.Worksheets(1)
        
        xlApp.Range("C1").Select
        xlApp.ActiveCell.FormulaR1C1 = "=SUM(A1:B1)"
        
        xlApp.Visible = True
    End Sub