VBA not working

cljim

New Member
Joined
Sep 23, 2014
Messages
4
Hi everybody, I formatted my computer and since then vba functions are not working. Before the format I used excel 2010 and everything worked great (vba functions), but after formatting I installed excel 2013 and it started.

When I create a function in vba (anyone), and after that I use the function in the spreadsheet it always returns the same error: #VALUE!

For example: I introduced this code in vba:

Function inandout(x, y)
inandout = x + y


End Function

after that I tried to use the formula for 5,2 = I wrote in the bar: =inandout(5,2)

and it gives me the error: #VALUE!

That happens with all the function while before formatting it didn´t happen. I´ve already tried uninstalling the 2013 version and installing again the 2010, but it happens in this version too. Macros are allowed and the document is saved as a xslm. Could you help me to fix this?

Thank you so much in advance
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
cljim,

Welcome to the MrExcel forum.

Here is an update to your function:

Code:
Function inandoutV2(x, y) As Long
' hiker95, 09/23/2014, ME807270
inandoutV2 = x + y
End Function


<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>B</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;">7</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;">112</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B4</th><td style="text-align:left">=inandoutV2(<font color="Blue">5,2</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">B5</th><td style="text-align:left">=inandoutV2(<font color="Blue">12,100</font>)</td></tr></tbody></table></td></tr></table><br />
 
Last edited:

cljim

New Member
Joined
Sep 23, 2014
Messages
4
Thank you so much for your help hiker95 but it´s not working, I´ve tried a lot of functions without result. It always gives me back the error:#VALUE!

 

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
cljim,

I had placed the function code in a Module in the active workbook.

Where does your function code reside?
 

cljim

New Member
Joined
Sep 23, 2014
Messages
4

ADVERTISEMENT

It´s in the module of the active workbook too...
 

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
cljim,

The new function works correctly in Excel 2007, from a module in the active workbook.

I have no experience with Excel 2013.


Click on the Reply to Thread button, and just put the word BUMP in the thread. Then, click on the Post Quick Reply button, and someone else will assist you.
 

cljim

New Member
Joined
Sep 23, 2014
Messages
4

ADVERTISEMENT

cljim,

The new function works correctly in Excel 2007, from a module in the active workbook.

I have no experience with Excel 2013.


Click on the Reply to Thread button, and just put the word BUMP in the thread. Then, click on the Post Quick Reply button, and someone else will assist you.

Hi Hiker95,

First of all thank you for your help. I tried in both excel 2010 and 2013 without results. I have uninstalled office and install it again four times but it seems like an internal problem. I´ve noticed that functions with only one variable works correctly, e.g:
Function first(x)
first = x
End Function

But when I try to add another variable it returns the error.

Do you know which could be the problem? I need vba for a class.

Thank you.
 

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
cljim,

First of all thank you for your help.

You are very welcome. Sorry that I was not able to solve your request.


Do you know which could be the problem?

I do not have a clue.


I need vba for a class.

Try asking one of the other students, or, one of the teachers.


And, also try:

Click on the Reply to Thread button, and just put the word BUMP in the thread. Then, click on the Post Quick Reply button, and someone else will assist you.
 

Jerry Sullivan

MrExcel MVP
Joined
Mar 18, 2010
Messages
8,787
cljim,

It's possible that you don't have the VBA Library referenced by your VBA project.

From the VBA Editor: Tools > References
On the Available References list, look for "Visual Basic For Applications" and make sure it is checked.

EDIT: I just noticed in Post #7 that some User Defined Functions worked for you after your reinstall, so what I describe above probably isn't the problem.
Nonetheless, it may be worth checking.
 
Last edited:

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,307
Office Version
  1. 2010
Platform
  1. Windows
When I create a function in vba (anyone), and after that I use the function in the spreadsheet it always returns the same error: #VALUE!

For example: I introduced this code in vba:

Function inandout(x, y)
inandout = x + y


End Function

after that I tried to use the formula for 5,2 = I wrote in the bar: =inandout(5,2)
I´ve noticed that functions with only one variable works correctly
What is the separator that you use between arguments when you use the built-in Excel functions? IF it is a semi-colon, then you must use a semi-colon when you call your UDF in a worksheet formula like this...

=inandout(x;y)

You would only use a comma if you use commas to separate your argument with built-in functions (in VB code that may call your code, there you would use a comma no matter what you use on the worksheet).
 

Watch MrExcel Video

Forum statistics

Threads
1,108,956
Messages
5,525,885
Members
409,669
Latest member
JDCupps

This Week's Hot Topics

Top