Thread: custom function
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
dave!! dave!! is offline
external usenet poster
 
Posts: 10
Default custom function

Thanks, I had just figured it out.

Another question though...

I need a function that will look at a range of values (sorted in ascending
order) and find the value just below some desired value.

For example, if I had a list of 1, 2, 3, 4, 5 and my value was 2.5, the
function would return 2.

Thanks
"JE McGimpsey" wrote in message
...
Not sure you need code. Using a worksheet function:

=TREND({2,1},{12,24},15)

But you could use code:

Public Function Interpolate(Point1, Value1, Point2, Value2, Point3)
Interpolate = (Value1 - Value2) * _
((Point2 - Point3) / (Point2 - Point1)) + Value2
End Function


In article ,
"dave!!" wrote:

Does anyone have any code (or at least enough to get me started) to

perform
a linear interpolation of points? I want something with the following
inputs...

Point 1: 12
Value 1: 2.000
Point 2: 24
Value 2: 1.000
Desired Point: 15
Round: 3

Output would be 1.750

Formula would be as follows:
{(Value 1 - Value 2) x [(Point 2 - Desired Point)/(Point 2 - Point 1)]}

+
Value 2

Thanks!!
Dave