How would one write a user-defined-function for calculating the Cross Section Inside Pipe Area?
Can this be achieved?
JS
How would one write a user-defined-function for calculating the Cross Section Inside Pipe Area?
Can this be achieved?
JS
Is there a specific part of building such a UDF that you need help with.
I might suggest that you start with this tutorial that I wrote: http://www.excelforum.com/tips-and-t...uild-udfs.html This tutorial and the accompanying links will give you some basic ideas on how to structure a UDF and some of the debugging steps that I use to build a UDF.
Then, visit your favorite geometry tutorial to make sure that you know and understand the mathematical formulas for cross section of pipe.
Then, build your UDF. Be sure to pass appropriate arguments through the argument list.
Let us know where you get stuck.
Originally Posted by shg
In VBA
for a worksheet function, try =PI()Please Login or Register to view this content.
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
Thanks MrShorty
I will read the tutorial and then see how i go
Best Regards
JS
Hi Mike
Could you please explain how you would use in VBA
Best regards
JS
For your attached file, I wouldn't use VBA, I would use worksheet formulas to calculate the result.
Responding to your thread title, my post was pointing out that there is a built-in worksheet function PI() that isn't available in VBA (Other than through the WorksheetFunction object). If you are working in VBA, I posted one of the many ways to calculate pi.
Thanking you
The goal is an easy example to show how to create and use a UDF.
Most Engineers, prefer using diameter rather than radius which is your di/2 since r=d/2. That is because diameter can easily be measured. As an Engineer, I use diameter for that very reason, most of the time...
I normally measure 3 equidistant locations for diameter and average them.Please Login or Register to view this content.
Last edited by Kenneth Hobson; 06-29-2016 at 10:57 AM.
Here's the UDF if you want it. It needs to be placed in a Module. Then you would call it like
=Pipe_CS_Area(73)
Thanks to @mikerickson for the new way to calculate pi.Please Login or Register to view this content.
I'm interested in starting a career working with VBA, if anyone knows of any opportunities!
Why use a transcendental function to calculate a constant?
Please Login or Register to view this content.
Last edited by shg; 06-29-2016 at 11:17 AM.
Entia non sunt multiplicanda sine necessitate
Not to your computer; it's a rational number (someInteger/2^something) whose value need not be calculated.
Like Mike said, there are several ways to set a value for pi. SHG's constant method is fine too.
Like pi, the discussion has not been Vulgar. Pi history is certainly interesting. I do well to memorize 4 decimal places, much less 70,000. https://en.wikipedia.org/wiki/Pi
It is a pet peeve of mine though when the best approximation of pi is not used. In the old days when slide rules ruled, that was fine. I still have one, somewhere. For kicks, it might be fun to dig it out and see if I can remember how I used it. https://en.wikipedia.org/wiki/Slide_rule
The OP has his answer, and then some, so all is good.
22/7 is actually a very close approximation.
=(22/7)/ PI() returns 1.000402499
Or 245850922/78256779, which returns the same value as =PI()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks