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
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

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



Excel 2007
B
47
5112
Sheet1
Cell Formulas
RangeFormula
B4=inandoutV2(5,2)
B5=inandoutV2(12,100)
 
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
37,866
Office Version
  1. 2019
  2. 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).
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,487
Messages
5,831,988
Members
430,100
Latest member
namhnz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top