FormulaR1C1不适用于SUMME

FormulaR1C1方法不能像预期的那样工作。

objExcel = CreateObject("Excel.Application") objWorkbook = objExcel.Workbooks.Add Dim Formula As String Formula = "=SUMME(Z1S1;Z2S1)" For i = 1 To 5 Step 1 objWorkbook.Worksheets("Tabelle1").Cells(i, 1).FormulaR1C1 = 5 objWorkbook.Worksheets("Tabelle1").Cells(i, 5).FormulaR1C1 = "Text" objWorkbook.Worksheets("Tabelle1").Cells(i, 3).FormulaR1C1 = Formula Next 

这应该在第三列给我10次5次,但是没有。 我甚至尝试过:

 Formula = "=SUMME(Z[0]S[-2];Z[1]S[-2])" 

但是这也行不通。 Loop到达分配线时会中断:。如果我尝试使用

 Formula = "=SUMME(Z1S1,Z2S1)" 

它完全执行,但它不适用于Excel,因为它在Excel字段中说= SUMME('Z1S1';'Z2S1')

如果您打算使用包含非EN-USfunction的string,则必须使用Range.FormulaLocal属性或Range.FormulaR1C1Local属性 。 VB.Net 需要一个EN-US公式,并将其转换为工作表的区域语言。

 Formula = "=SUM(A1, B2)" 'or depending on your requiements, Formula = "=SUM(A1:B2)" .Formula = Formula Formula = "=SUM(R1C1, R2C2)" 'or depending on your requiements, Formula = "=SUM(R1C1:R2C2)" .FormulaR1C1 = Formula Formula = "=SUMME(Z1S1;Z2S1)" 'or depending on your requirements, Formula = "=SUMME(Z1S1:Z2S1)" .FormulaLocalR1C1 = Formula 

不要将xlA1单元格引用与xlR1C1引用混淆。 R23意味着xlA1中的细胞(23,18)和xlR1C1中的23:23。

请注意,使用Range.Formula属性或Range.FormulaR1C1属性强制使用逗号(EN-US标准)而不是分号作为系统列表分隔符。


Range.Formula属性
Range.FormulaR1C1属性
Range.FormulaLocal属性
Range.FormulaR1C1Local属性