Excel VBA: passing arguments

I am working on some Excel functions using VB, but I am stuck on some examples. The current version is Excel 2007, using an empty workbook; I added to the module and tried to perform the following functions:

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

However, I get the error #VALUE! in my cell when I do Addtwo (5.5). When trying to make Addtwo (B2, B3) Excel tells me that my formula is incorrect.

Thank,

+3
source share
1 answer

Nested code is fine and works in my Excel 2007.

The only possible problems I can think of are:

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

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

+5
source

All Articles