Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Using PI in a macro

I know PI can be used in a formula in for a cell. I am writing a macro to
provide the same formula while process other data.

When I try to use it, I get a compile error, sub or function not defined.

It is a complicated formula but (Cos(D1031 * Pi() / 180)......

Is there some thing I have to use PI?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using PI in a macro

You can use Application.Pi. E.g,

(Cos(D1031 * Application.Pi() / 180)......


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Nils Titley" wrote in message
...
I know PI can be used in a formula in for a cell. I am writing a macro to
provide the same formula while process other data.

When I try to use it, I get a compile error, sub or function not defined.

It is a complicated formula but (Cos(D1031 * Pi() / 180)......

Is there some thing I have to use PI?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Using PI in a macro

pi = 4*Atn(1)
--
Gary''s Student - gsnu200773
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Using PI in a macro

When I try to use it (Pi() ), I get a compile error, sub or function not
defined


Hi. You need to use "WorksheetFunction.Pi"
However, this looks terrible in a formula.
Here are some general ideas for using a variable.

Sub Demo1()
Debug.Print WorksheetFunction.Pi

Dim Pi, Deg
Pi = [Pi()]
Deg = [Pi()/180]

Debug.Print Pi
Debug.Print Sin(90 * Deg)
End Sub

If you have a little imagination, here is Character 0182 used as Pi.
Probably not useful though.

Sub Demo2()
Dim ¶ As Double 'Alt + 0182
¶ = [Pi()]
Debug.Print Cos(45 * ¶ / 180)
End Sub

--
HTH :)
Dana DeLouis


"Nils Titley" wrote in message
...
I know PI can be used in a formula in for a cell. I am writing a macro to
provide the same formula while process other data.

When I try to use it, I get a compile error, sub or function not defined.

It is a complicated formula but (Cos(D1031 * Pi() / 180)......

Is there some thing I have to use PI?

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Using PI in a macro

Thanks all for responding. I am using the Application.Pi(). It is working
but I will also try the others.



"Nils Titley" wrote:

I know PI can be used in a formula in for a cell. I am writing a macro to
provide the same formula while process other data.

When I try to use it, I get a compile error, sub or function not defined.

It is a complicated formula but (Cos(D1031 * Pi() / 180)......

Is there some thing I have to use PI?

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"