VBA不接受我的方法调用并给出编译错误:语法错误 [英] VBA does not accept my method calling and gives Compile error: Syntax error

查看:220
本文介绍了VBA不接受我的方法调用并给出编译错误:语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

公开Sub SavePendleValues(ByVal row1 As Integer,ByVal row2 As Integer)

调用它

 对于sheetrow = 2到15'要扫描的行数
SavePendleValues(sheetrow ,工作单)
下一个工作单

获取错误:编译错误:语法错误



当我取消注释行时: SavePendleValues(sheetrow,sheetrow) / p>

一切正常。

解决方案

删除括号

  SavePendleValues工作表,工作表

否则,您尝试作为第一个参数传递一些括号中的两个变量,对于VBA解析器来说是有意义的。


Public Sub SavePendleValues(ByVal row1 As Integer, ByVal row2 As Integer)

Calling it

For sheetrow = 2 To 15 ' number of rows to scan
    SavePendleValues (sheetrow, sheetrow)
Next sheetrow

Getting error : Compile error: Syntax error

When I uncomment the line: SavePendleValues (sheetrow, sheetrow)

Everything works.

解决方案

Remove the parentheses.

SavePendleValues sheetrow, sheetrow

Otherwise you are trying to pass as a first argument something in parentheses that has two variables in it, which doesn't make sense for VBA parser.

这篇关于VBA不接受我的方法调用并给出编译错误:语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆