+ Reply to Thread
Results 1 to 5 of 5

Problem using VBA functions....

  1. #1
    Richard Latter
    Guest

    Problem using VBA functions....

    Hello All,

    Function Celsius(dFahrenheit As Double) As Double
    Celsius = (dFahrenheit - 32) * (5 / 9)
    End Function

    As a demo, I have been trying to get a simple VBA function to work
    using Excel without success. I believe I've created it successfully
    using the Visual Basic Script Editor. I have tried using it in a
    worksheet, but whenever I try the formula in a cell, I keep getting
    #NAME?.

    EG. Cell A2 "=Celsius(3)"

    No matter what I try to do, it will not accept this formula even
    though I believe it's correct. From my investigation, it appears that
    the worksheet for whatever reason cannot see this function I have
    created, but I do no understand why.

    Can anyone help?

    In addition, I have installed the atpvbaen.xls and funcres.xla
    add-ins. However, if I try to access these in the project manager, it
    prompts me for a password (which I do not know). Is this normal?

    Many thanks in advance,

    Richard

    BTW Subroutines do work under VBA.

  2. #2
    JE McGimpsey
    Guest

    Re: Problem using VBA functions....

    Put the code in a regular code module (in the VBE, Insert/Module).




    In article <[email protected]>,
    [email protected] (Richard Latter) wrote:

    > Hello All,
    >
    > Function Celsius(dFahrenheit As Double) As Double
    > Celsius = (dFahrenheit - 32) * (5 / 9)
    > End Function
    >
    > As a demo, I have been trying to get a simple VBA function to work
    > using Excel without success. I believe I've created it successfully
    > using the Visual Basic Script Editor. I have tried using it in a
    > worksheet, but whenever I try the formula in a cell, I keep getting
    > #NAME?.
    >
    > EG. Cell A2 "=Celsius(3)"
    >
    > No matter what I try to do, it will not accept this formula even
    > though I believe it's correct. From my investigation, it appears that
    > the worksheet for whatever reason cannot see this function I have
    > created, but I do no understand why.
    >
    > Can anyone help?
    >
    > In addition, I have installed the atpvbaen.xls and funcres.xla
    > add-ins. However, if I try to access these in the project manager, it
    > prompts me for a password (which I do not know). Is this normal?
    >
    > Many thanks in advance,
    >
    > Richard
    >
    > BTW Subroutines do work under VBA.


  3. #3
    Forum Contributor
    Join Date
    02-15-2005
    Location
    Blackpool, UK
    Posts
    137
    Alternatively....

    Got to menu Tools>Add-Ins, and check the Analysis Tool Pack option, press OK.

    The CONVERT worksheet function is now available.

    =CONVERT(A1, "F", "C")

    Art

  4. #4
    JulieD
    Guest

    Re: Problem using VBA functions....

    Hi Richard

    where did you put the function code .. if you put it in personal.xls you
    need to prefix the function name with personal e.g.
    =PERSONAL.XLS!Celsius(3)

    to check if this is the case, use the fx (paste function) icon and the
    user-defined category ... you should be able to see your function there.

    Cheers
    JulieD


    "Richard Latter" <[email protected]> wrote in message
    news:[email protected]...
    > Hello All,
    >
    > Function Celsius(dFahrenheit As Double) As Double
    > Celsius = (dFahrenheit - 32) * (5 / 9)
    > End Function
    >
    > As a demo, I have been trying to get a simple VBA function to work
    > using Excel without success. I believe I've created it successfully
    > using the Visual Basic Script Editor. I have tried using it in a
    > worksheet, but whenever I try the formula in a cell, I keep getting
    > #NAME?.
    >
    > EG. Cell A2 "=Celsius(3)"
    >
    > No matter what I try to do, it will not accept this formula even
    > though I believe it's correct. From my investigation, it appears that
    > the worksheet for whatever reason cannot see this function I have
    > created, but I do no understand why.
    >
    > Can anyone help?
    >
    > In addition, I have installed the atpvbaen.xls and funcres.xla
    > add-ins. However, if I try to access these in the project manager, it
    > prompts me for a password (which I do not know). Is this normal?
    >
    > Many thanks in advance,
    >
    > Richard
    >
    > BTW Subroutines do work under VBA.




  5. #5
    Gord Dibben
    Guest

    Re: Problem using VBA functions....

    On 28 Feb 2005 05:05:49 -0800, [email protected] (Richard Latter)
    wrote:

    >In addition, I have installed the atpvbaen.xls and funcres.xla
    >add-ins. However, if I try to access these in the project manager, it
    >prompts me for a password (which I do not know). Is this normal?


    Yes, this is normal.

    Those two are Excel add-ins and are protected.

    You don't need those loaded to run your Function.

    Follow the suggestions posted by Julie or JE.


    Gord Dibben Excel MVP

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1