Consulting

Results 1 to 3 of 3

Thread: Solved: Calling a function from a worksheet formula

  1. #1

    Solved: Calling a function from a worksheet formula

    I am using excel 2007. I am trying to call a function from a worksheet formula. This is an example from a book, but I cannot get it to work. Here is my code

    Sub CallerSub()
    MsgBox CubeRoot()
    End Sub
    Function CubeRoot(number)
    CubeRoot = number ^ (1 / 3)
    End Function


    I am trying to call the function by typing in a cell =CubeRoot(1728). The error I get says "Ambiguous Name Detected: Cube Root"

    What did I do wrong?

    Thanks,

    Rodney

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    It sounds like you have two routines named CubeRoot.
    Where is the code that you posted, in a normal module or a sheet's code module?

    In the VBEditor, use Find to look for CubeRoot and mark the search through entire project box. That should find the duplicate declaration.

  3. #3
    The code was in a normal module. You were right, I had more than one module with CubeRoot in it. Thanks.

Posting Permissions

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