function in Macro always return zero

genie_0582

New Member
Joined
Apr 18, 2011
Messages
3
Hi,

I could not find a thread that talk about this problem, and i do hope there is a solution. I write a very simple Public Function as follow

Public Function y (x As Single) As Single

y=x+5

End Function

When i try it, it gives 0.
When i try it again, it gives the correct answer.

seems like it's not stable.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
It works for me. How are you calling the function?

Although I gotta ask why are you writing a UDF to just add 5 to a number?
 
Upvote 0
:D haha. thanks for solving my problem. This function is just to test whether it works or not. Nothing particular in this function. Anyway, I post it here and i figured it out by myself. For Excel 2011, we have to save the file, so that we can use the function. :biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

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
Back
Top