预计函数或变量

语句的语法指示变量或函数调用。 此错误具有以下原因和解决方案:

  • 名称不是已知变量或 函数 过程的名称。

    Check the spelling of the name. Make sure that any variable or function with that name is visible in the portion of the program from which you are referencing it. 例如,如果函数定义为 Private 或变量未定义为 Public,则它仅在其自己的 模块中可见。

  • 您正在尝试以不适当的方式向过程名称分配值。

    例如,如果 MySubSub 过程,则以下代码将生成此错误:

    MySub = 237    ' Causes Expected Function or variable error
    

    虽然您可使用包含 Property Let 过程或包含返回对象或包含对象的 变量函数 的分配语法,但不可使用包含 SubProperty GetProperty Set 过程的分配语法。

有关其他信息,选择有问题的项并按 F1(在 Windows 中)或 HELP(在 Macintosh 上)。

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。