View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
JCDW JCDW is offline
external usenet poster
 
Posts: 3
Default Simple VBA Module functions do not work on the worksheet!

What is a 'regular' code module. For that matter, what is an 'irregular'
code module. Yes, I'm just getting started studying VBA, but I sure got hung
up in a hurry! And how do I go about rating the responses I've been getting?
Sites like this are a gold mine! It's difficult for me to accept that so
many people will attempt to help so many who need it! Tks.

"JE McGimpsey" wrote:

While you should probably put your function in a regular code module,
you CAN call it like this (assuming it's in the Sheet1 code module):

=Sheet1.Cuberoot(x)

Note that I'm assuming you meant

Public Function CubeRoot(num As Double) As Double
CubeRoot = num ^ (1 / 3)
End Function

In article ,
JCDW wrote:

In both Excel 2000 and 2007 when I enter the following functions on a
worksheet module (or the Excel obect page 'behind' the worksheet), I am
unable to execute (or call) on the worksheet. I get the error, [ #NAME? ].

Sub ShowSum()
Sum = 1 + 1
MsgBox "The answer is " & Sum
End Sub

Function CubeRoot() ' returns the cube root of a number
CubeRoot = num ^ (1 / 3)
End Function