Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
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
 
Old July 22nd, 2006, 07:09 PM
Authorized User
 
Join Date: Jul 2006
Location: Kalamazoo, MI, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
 
Old July 22nd, 2006, 07:53 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Are you able to post part or all of the function? That might help us track down the cause.

Mike



Mike
EchoVue.com
 
Old July 22nd, 2006, 08:19 PM
Authorized User
 
Join Date: Jul 2006
Location: Kalamazoo, MI, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old July 22nd, 2006, 08:43 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Try something like this...

Public Function PMRRATE(Customer as Variant, Pickup as Variant, Drop as Variant)
    PMRRATE = 1
End Function


Mike
EchoVue.com
 
Old July 22nd, 2006, 09:35 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Any luck with that?

Oh, And welcome to the forum [:-)]


Mike
EchoVue.com
 
Old July 23rd, 2006, 05:53 AM
Authorized User
 
Join Date: Jul 2006
Location: Kalamazoo, MI, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old July 23rd, 2006, 06:56 AM
Authorized User
 
Join Date: Jul 2006
Location: Kalamazoo, MI, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old July 23rd, 2006, 11:40 AM
Authorized User
 
Join Date: Jul 2006
Location: , , Poland.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old July 23rd, 2006, 02:56 PM
Authorized User
 
Join Date: Jul 2006
Location: Kalamazoo, MI, USA.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old July 24th, 2006, 12:05 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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




Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 VBA - Need to open a workbook in a fold bablhous BOOK: Excel 2003 VBA Programmer's Reference 0 December 21st, 2006 02:50 PM
FTP Upload from Excel 2003 VBA Jersey Eric Excel VBA 3 January 5th, 2006 09:29 AM
excel 2003 vba book xeugx Excel VBA 3 June 27th, 2005 11:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.