I tried to create a custom function named "AddTwo" which add two arguments but It won't work.
Please Login or Register to view this content.
I tried to create a custom function named "AddTwo" which add two arguments but It won't work.
Please Login or Register to view this content.
Last edited by zanshin777; 10-21-2015 at 06:35 AM.
I don't see any code anywhere in your project.
For a UDF like, that I would put the code into a normal module (not a sheet's code module or the ThisWorkbook module or a Class module)
Once the code is in the module, the custom function, called a UDF (User Defined Function), can be used in a worksheet formula like the one in Sheet1!H6 of the attached.
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
Hi,
Put this function in a modula, and you can call it after you've saved your workbook before using the function.
You didn't specify the kind of variable you want to be returned.
Please Login or Register to view this content.
Greetings,
Cheetahke
@zanshin777
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.
Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
(This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
I edited the thread.
Hi,
You can try this:
Please Login or Register to view this content.
It won't work. #VALUE error.
Post a workbook with the UDF installed and an example that shows an error.
Entia non sunt multiplicanda sine necessitate
Sorry. It was because I use "," rather than ";"
Formula:Please Login or Register to view this content.
Why Is there "As Double" in into line? (So, There isn't a variable. Is It?)
I am not certain exactly what your question is. The only use of "As Double" in your code is to designate the data type for the function value. The function is technically not a "variable". However, like a variable, a function has a data type, and we, as programmers, can explicitly declare that data type so that VBA will generate errors if we mistakenly try to assign incorrect data to the function, or if we try to assign the function's result to a variable of the wrong data type. Explicitly declaring a function's data type has many of the same advantages (and limitations) as explicitly declaring a variable's data type in a Dim statement.
Originally Posted by shg
The lineis saying that the value returned by function SumArray will be data type Double.Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks