+ Reply to Thread
Results 1 to 7 of 7

VBA Linear Interpolation

  1. #1
    Registered User
    Join Date
    01-05-2010
    Location
    liverpool, england
    MS-Off Ver
    Excel 2007
    Posts
    44

    VBA Linear Interpolation

    Hi All

    I have a quarterly US GDP data from 1980 to date. The problem I have is given the data is only produced quarterly I have gaps in the data. This is fine when drawing a chart in excel as you can simply join data points however, an external provider I use to publish charts does not have this feature on its software and I am required to provide a value for every date. I therefore need to interpolate (linear) the values between data points. This is easily done manually on a small data set however I wonder if anyone has a piece of VBA code to speed things up.

    Thanks
    Last edited by WAW; 10-25-2010 at 04:56 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA Linear Interpolation

    Post a workbook.

  3. #3
    Registered User
    Join Date
    01-05-2010
    Location
    liverpool, england
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: VBA Linear Interpolation

    Ive enclosed the sample spread sheet.

    Thanks
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-05-2010
    Location
    liverpool, england
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: VBA Linear Interpolation

    Any one have any ideas on this one?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA Linear Interpolation

    There's one value for GDP, which makes it a little hard to see what you want interpolated.

    EDIT: Never mind, I see it ...

    You want GDP for every day?? That's kind of empty magnification, isn't it?
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA Linear Interpolation

    I used AutoFilter to extract the quarterly numbers, and a UDF to do the interpolation:

    Please Login or Register  to view this content.
    The formula in E2 and down is

    =LINTERP(D2, $A$2:$A$121, $B$2:$B$121)

    Here's the UDF:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-05-2010
    Location
    liverpool, england
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: VBA Linear Interpolation

    Hi Shg

    Fantastic!!! does the job perfectly, this will save me a few hours of doing it manually,

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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