Create a custom worksheet function in Excel VBA
Posted
by Tomalak
on Stack Overflow
See other posts from Stack Overflow
or by Tomalak
Published on 2009-04-16T11:59:03Z
Indexed on
2010/03/23
14:53 UTC
Read the original article
Hit count: 608
I have a faint memory of being able to use VBA functions to calculate values in Excel, like this (as the cell formula):
=MyCustomFunction(A3)
Can this be done?
EDIT:
This is my VBA function signature:
Public Function MyCustomFunction(str As String) As String
The function sits in the ThisWorkbook
module. If I try to use it in the worksheet as shown above, I get the #NAME?
error.
Solution (Thanks, codeape): The function is not accessible when it is defined ThisWorkbook
module. It must be in a "proper" module, one that has been added manually to the workbook.
© Stack Overflow or respective owner