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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i write user-defined formula

Status
Not open for further replies.

jackha18

Technical User
Sep 28, 2002
39
IL
what are the steps of writing user-defined formula in excel?
i tried to insert publice functions in workbook module, class module, macros workbook - it didn't work. is there some special syntax?
thanks.
 
It is the same as a procedure!
Code:
Sub MyProcedure()

End Sub
For a function
Code:
Function MyFunction()

End Function
Maybe there was something wrong with your code? Let's see!

Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
actually, i started with a test code:

Public Function xxx() As String
xxx = "ok"
End Function

i saved the workbook and the entered

=xxx()

into a cell, which gave me #NAME?

 
i tried to enter both =xxx() and =xxx.
any ideas, guys? it should be so simple, i'm sure.
mike, if you're saying the syntax is the same as any other procedure it means i can enter ANY macro name into a cell as formula and run it in such a way. it seems strange to me...
can anybody just drop me a working sample xls with user-defined function to j322223@hotmail.com ? i'd highly appreciated it.
 
The test code from your second post works just fine if it is placed in a code module. Insert/Module from the menu in the VBA editor.

I'm guessing you are putting the code on a worksheet code page or a workbook code page.
 
that's right! incredible, what a stupid and simple mistake!
thanks to all of you, folks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top