Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

functions in personal.xls -> #name? error 1

Status
Not open for further replies.

electricpete

Technical User
Oct 1, 2002
289
US
I am able to put macros (subs without arguments) in my personal.xls file, and they are available for running in any spreadsheet via the Tools / Macro / Run menu.

But when I try to invoke a function from my personal.xls, I get an error #name?

Why is it that a workbook can pull a sub from another workbook (personal.xls), but a workbook can't pull a function from another workbook?

The function is:
Public Function getformula(mycell As Range) As String
getformula = mycell.Formula
End Function

That function is declared in module1 (a standard module) of my personal.xls. Right below it is a macro subroutine which runs fine.
 
How are you trying to invoke the function?

If on a worksheet, it may need to be called as:

=Personal.xls!GetFormula(A1)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Agree with xlboo.

If you open a new workbook and you just type in suppose A1.

=Getformula(a2)

You will get #name error because the openned workbook doesn't know where to find the Getformula (sub or function).

One approach would be to reference that particular workbook like: =Personal.xls!getformula(a2)

Another approach would be to establish a direct relation thru tool / references (in VB editor) and selecting the workbook. Note that all the workbooks open will be shown as VBA Project. You could also browse to find your file.
Personal.xls is usually in the Xlstart folder.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top