使用用户定义范围编写单元格引用公式

时间:2013-09-24 12:51:46

标签: excel vba formula

这是一个非常简单的问题......我刚刚陷入语法困境。

如何更改此公式以使其符合vba:

    Dim sum_rng As Range
    Set sum_rng = Range(Cells(strt_pt(end_ct), j), Cells(end_pt(end_ct), j))
    'Debug.Print sum_rng

    Cells(47, lent + 2).Formula = "=AVERAGE(IF(ISNUMBER(" & sum_rng & ")," & sum_rng & ")"

阵列和其他一切看起来很好,我认为问题是.Formula vs.FormulaR1C1或其他东西。

1 个答案:

答案 0 :(得分:1)

我认为你错过了父母。见最后一行的结尾

Dim sum_rng As Range
Set sum_rng = Range(Cells(strt_pt(end_ct), j), Cells(end_pt(end_ct), j))
'Debug.Print sum_rng

Cells(47, lent + 2).Formula = "=AVERAGE(IF(ISNUMBER(" & sum_rng & ")," & sum_rng & "))"