PDA

View Full Version : Solved: Calling a function from a worksheet formula



rodneywead
04-15-2011, 03:08 PM
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

mikerickson
04-15-2011, 06:29 PM
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.

rodneywead
04-15-2011, 06:44 PM
The code was in a normal module. You were right, I had more than one module with CubeRoot in it. Thanks.