开发者

Excel VBA: passing arguments

I am working on some Excel functionality using VB - but I am getting stuck at some examples. Current version is Excel 2007, using a blank Workbook; I've added in a module and trying a function like the following:

Function Addtwo(a, b)
  Addtwo = a + b
End Function

However, I get the error #VALUE! in my cell, when doing Addtwo(5,5). When trying to 开发者_JAVA技巧do Addtwo(B2,B3), Excel tells me my formula is wrong.

Thanks,


The pasted code is okay and works in my Excel 2007.

The only possible problems I can think of:

  • You forgot to use the equal sign: Addtwo(5,5) instead of =Addtwo(5,5)

  • Your language settings require a semicolon instead of a comma in the formula, i.e. =Addtwo(5;5) (in the worksheet formula only, not in the VBA code)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜