请问,VB6.0 中如何在 excel 表里设置公式呢,我试着通过建立 excel 对象的方式设置公式,发现公式里的列名都成了文本型,都带有单引号,请各朋友帮忙啊我是这样设置的 xlSheet.Cells(1, 1).FormulaR1C1 = "=sum(A2:A5)"结果到 excel 单元格里变成了这样     =sum('A2':'A5')   这是为什么呢?那位高手帮帮忙啊

解决方案 »

  1.   

    '在工程中引用 Microsoft office 11.0 Object
    Private Sub Command1_Click()
    Set ex = CreateObject("Excel.Application")
    Set wb = ex.workbooks.Add       '新建EXCEL
    Set sh = wb.Sheets(1)
       '  SumB = "=SUM(A2:A5)"
      sh.Cells(1, 1) = "=SUM(A2:A5)"
     ex.Visible = True
      Set ex = Nothing
      Set wb = Nothing
      Set sh = Nothing
    End Sub
      

  2.   

    在Excel里的公式怎么写,在VB中就怎么写!
      

  3.   

    Excel有两种公式表示法,不要搞错了,下面两个等价
        xlSheet.Cells(1, 1).FormulaR1C1 = "=SUM(R[1]C:R[4]C)"
        xlSheet.Cells(1, 1).Formula = "=SUM(A2:A5)"