Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Module in Excel 2

Status
Not open for further replies.

enirwin

Mechanical
Feb 14, 2002
46
I'm trying to create a custom function in Excel using a VBA module. My problem is that I can't get Pi to work. If I enter 3.14 my function works properly. If I use Pi I get an error. It seems to be using 0 for Pi.

For now, I'm using 3.14159265358979 for Pi, but I'd rather just use Pi. Can anyone help?

Thanks.
 
Replies continue below

Recommended for you

You need Excel.WorksheetFunction.Pi()

Example
Function test()
MsgBox (Excel.WorksheetFunction.Pi())
End Function

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
I recommend using a constant as follows

Const PI as Double= 3.14159265358979


Then you can use it in Functions

A=PI*D*D/4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor