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)
精彩评论