vba := 预期为 sub

vba := expected for a sub

我有一个程序:

Sub FormulaToNumber(sheetName As String, sheetRange As String)
Dim sh As Worksheet, Cell As Range, Plage As Range
Set sh = Worksheets(sheetName)

    sh.Select

    With sh

    Set Plage = .Range(sheetRange)

    For Each Cell In Plage
        Cell.Value = Format(Cell.Value, "Fixed")
    Next

    End With
    Application.CutCopyMode = False

End Sub

我正在尝试这样调用我的程序:

FormulaToNumber("temps_ress", "D3:O95")

但是 Excel 不能让我调用我的程序,一个消息框出现了这个文本: "Error := expected" 我认为它想要一个类似的命题:FormulaToNumber("temps_ress", "D3:O95") = variable,但是为什么?!

:= 运算符用于调用带有 命名参数 的 function/procedure... 但我看不到您尝试的任何地方要做到这一点。然而...

And I am trying to call my procedure like that :

FormulaToNumber("temps_ress", "D3:O95")

去掉括号:

FormulaToNumber "temps_ress", "D3:O95"

您可以简单地使用以下两个选项之一:

Call FormulaToNumber("temps_ress", "D3:O95")

FormulaToNumber "temps_ress", "D3:O95"