Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default custom function

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default custom function

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default custom function

Take a look at LOOKUP in XL Help.

In article ,
"dave!!" wrote:

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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default custom function


Dave,
How is the user going to input or select the values for Point 1
Point 2, Value 1, Value 2 and Desired Point?
Are these values already part of a worksheet or do you want them t
input the values into a userform?

In any case just assign appropriate variables to the correspondin
variable source then use the varialbes in a formula as you typed

--
bhofset
-----------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...fo&userid=1880
View this thread: http://www.excelforum.com/showthread.php?threadid=37950

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
Custom Function SPeterson Excel Discussion (Misc queries) 3 December 21st 05 07:12 PM
Custom Function: Detecting the cell the function is used in g-boy Excel Programming 2 June 11th 05 06:46 PM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM
custom function - with built-in function VilMarci Excel Programming 14 January 25th 05 04:15 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM


All times are GMT +1. The time now is 09:19 AM.

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"