+ Reply to Thread
Results 1 to 6 of 6

Interpolate missing data

  1. #1
    Registered User
    Join Date
    10-12-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    8

    Interpolate missing data

    Hi,
    I'm looking for a VB script for interpolating missing data. Here is an example. I would like to interpolate the values in cells Y2 and Y3 using X1, X4, Y1 and Y4 values. Similarly, I would like to interpolate the values in cells Y6/7/8 using the values X5, X9, Y5, and Y9. Thanks!
    X Y
    0 1
    1
    2
    3 4
    4 5
    5
    6
    7
    8 9

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Interpolate missing data

    Condense your data to just know y and known x values then use the linest function.

    If you post your worksheet someone (or I) will show you how.
    Happy with my advice? Click on the * reputation button below

  3. #3
    Registered User
    Join Date
    10-12-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    8

    Re: Interpolate missing data

    Please see the attached file for example. I would like to interpolate across the active range B2:D12 as Yvalues using A1:A12 as Xvalues.
    <w w w . excelforum.com/attachment.php?attachmentid=693448&stc=1&d=1598972839>
    Attached Files Attached Files

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Interpolate missing data

    See the attached.

    I took your first data set of x and y data only and condensed in in cells A14 to B19 to show just the pairs where you had full data.

    I then used the linest formula to determine determine the parameters of a line of best fit. Aline can be described in the form as y = mx + b. where m is the gradient of th eline and b in the y axis intercept. If you use the charting tool and add a trend line and add the trendline formula you get the same form of equation shown on the chart too. I did this to show you that you get the same results as well.

    The linest formula returns two answers (the gradient, m, and the intercept b) to get two answers you need to set the formula as an array formula to spread those two answers over two cells. the way to do this is type =linest(b15:b19, a15,a19,false) into cell d15, then highlight cell d15 AND E15 then press control + shift + enter together. this puts the formula across the two cells an gives the two parameters for the line function.

    Now all you need to do to interpolate is to set up a column of y calculated data in column F and use the formula =A2*$D$15+$E$15 to apply the gradient and intercept to each x value and drag down.

    In this particular example your data doesn't represent much of a line so the line of best fit is a bit ordinary.

    I trust this is what you're after. If in stead you want to interpolate linearly between each individual data point then that's a different matter.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-12-2016
    Location
    US
    MS-Off Ver
    2013
    Posts
    8

    Re: Interpolate missing data

    Thank you! I was looking for a VB script, macro, or way to interpolate data between two points, using the data in the first column as X values.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Interpolate missing data

    Are you required to use Excel? Gnumeric with its built in INTERPOLATION() function makes short work of this. With Crooza's helper table in A15:B19, F2 becomes a simple =INTERPOLATION($A$15:$A$19,$B$15:$B$19,A2,0) copied/filled down to F12.

    If you must use Excel, you will need to build your own interpolation algorithm. I like an approach like this, that adds a couple more helper columns to Crooza's helper table, then performs some simple lookups along the way: https://www.excelforum.com/excel-for...ml#post5262186
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find missing values - interpolate data
    By marielouise1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-17-2017, 12:20 PM
  2. Interpolate missing data
    By ivanpersie in forum Excel General
    Replies: 5
    Last Post: 01-05-2017, 11:00 PM
  3. Interpolate between data
    By abduljaleel.mca in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2013, 10:41 AM
  4. Interpolate data
    By wenners68 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-14-2012, 05:22 AM
  5. VBA to interpolate missing values in table
    By adfo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2009, 12:08 PM
  6. Interpolate missing values
    By pilch in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2009, 06:59 AM
  7. [SOLVED] interpolate missing data between points
    By Rocket Rod in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-27-2005, 04:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1