 |
| Excel VBA Discuss using VBA for Excel programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 22nd, 2006, 07:09 PM
|
|
Authorized User
|
|
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Excel 2003 VBA Function
I have written a Function in VBA for Excel 2003, but Excel does not recognize it. I get a "Formula contains unrecognized text" error. Any help on what I am going wrong?
|
|

July 22nd, 2006, 07:53 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Are you able to post part or all of the function? That might help us track down the cause.
Mike
Mike
EchoVue.com
|
|

July 22nd, 2006, 08:19 PM
|
|
Authorized User
|
|
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Actually, because I have been unable to get it to work at all, I made it very simple.
Here is the function in VBA:
Function PMRRATE(Customer, Pickup, Drop)
PMRRATE = 1
End Function
The call is simply this formula in a cell:
=PMRRATE(B6,C6,E6)
Thanks for your help.
|
|

July 22nd, 2006, 08:43 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Try something like this...
Public Function PMRRATE(Customer as Variant, Pickup as Variant, Drop as Variant)
PMRRATE = 1
End Function
Mike
EchoVue.com
|
|

July 22nd, 2006, 09:35 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Any luck with that?
Oh, And welcome to the forum [:-)]
Mike
EchoVue.com
|
|

July 23rd, 2006, 05:53 AM
|
|
Authorized User
|
|
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the welcome. And for the quick response to my questions.
No, that has made no difference. For whatever reason, the function is simply not being recognized.
|
|

July 23rd, 2006, 06:56 AM
|
|
Authorized User
|
|
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I tried just a blank worksheet with a simple function and get the same result. Is there a way that the function name should be "published" so that it shows up in the list of functions? How does it get recognized?
|
|

July 23rd, 2006, 11:40 AM
|
|
Authorized User
|
|
Join Date: Jul 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I put this functions (see bellow) in blank worksheet and both of them work correctly. I can write these functions handly or choose them from list of functions (user). Please try it.
Function WYNIK1(ALA, OLA, KASIA) As Variant
WYNIK1 = 5 * ALA + 2 * OLA + KASIA
End Function
Function PMRATE(Customer, Pickup, Drop) As Variant
PMRATE = 1
End Function
|
|

July 23rd, 2006, 02:56 PM
|
|
Authorized User
|
|
Join Date: Jul 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I put both of these functions in VB and called both of them from a blank worksheet. In both cases, I get #NAME? as a result. If I select the cell containing the call and click on Insert Function, the function is undefined.
|
|

July 24th, 2006, 12:05 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
Sorry for not getting back to you sooner...
In the VBA Editor, Right Click "Sheet 1" and choose Insert -> Module
Then paste your code into the module. Yell if that doesn't work, and I'll upload the spreadsheet I just threw together.
Mike
Mike
EchoVue.com
|
|
 |