首页 文章

单元格(x,y).formula在引用另一张表时会生成#NAME错误[重复]

提问于
浏览
1

这个问题在这里已有答案:

我正在尝试用公式填写几张单元格(“= ALS($ AFB $ 14- $ AFB $ 13输入!$ T $ 2,输入!$ U $ 2- $ AFB $ 14,0)”(如果公式,Excel是荷兰语,输入是同一文件中的另一张表 . 它填写正确的公式,但它给出了#Name-error . 如果我手动选择单元格并输入生成的确切公式VBA,excel正确识别它 . 我想我在提到其他表时做错了什么,但我不确定是什么

'Excel is in Dutch, this would be the English formula              
            'formula =  "=IF(" & Cells(row - 1, column).Address & "-" & Cells(row - 2, column).Address & "<" & Inp.Cells(sku + 1, 20).Address(External:=True) & ";" & Inp.Cells(sku + 1, 21).Address(External:=True) & "-" & Cells(row - 1, column).Address & ";0)"

            formula = "=ALS(" & Cells(row - 1, column).Address & "-" & Cells(row - 2, column).Address & "<" & Inp.Cells(sku + 1, 20).Address(External:=True) & "," & Inp.Cells(sku + 1, 21).Address(External:=True) & "-" & Cells(row - 1, column).Address & ",0)"


      MRP.Cells(16 * sku - 1, 827 + i).formula = formula

1 回答

  • 2

    无论何时使用 .Formula ,Excel都是荷兰语并不重要 . 它使用英语公式 .

    要使用荷兰语(或本地语言),请使用 .FormulaLocal . 要查看Excel中公式的一个很好的示例以及VBA如何引用它们,请在新工作簿上运行以下命令:

    Public Sub SelectAndTestMe()
        With Range("A1")
            .Formula = "=IF(A2=1,""OK"",""Not OK"")"
            Debug.Print .Formula
            Debug.Print .FormulaLocal
            Debug.Print .FormulaR1C1
        End With
    End Sub
    

    这是您将在即时窗口中获得的(如果您使用的是德语Excel):

    =IF(A2=1,"OK","Not OK")
    =WENN(A2=1;"OK";"Not OK")
    =IF(R[1]C=1,"OK","Not OK")
    

相关问题