+ Reply to Thread
Results 1 to 7 of 7

Interpolate values for different times

  1. #1
    Registered User
    Join Date
    04-22-2009
    Location
    Boston
    MS-Off Ver
    Excel 2013
    Posts
    68

    Interpolate values for different times

    Hi,

    I have collected several temperature values for a 24 hour period. Time is given in column A and values is in B. I want to interpolate and get the values for the times given in column D.Linear interpolation would suffice Please reply.
    I am attaching workbook here.

    Thanks
    K
    Attached Files Attached Files
    Last edited by kapilrakh; 05-14-2010 at 09:36 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Interpolate values for different times

    Not sure if I am reading this correctly or if there is data missing from your sample sheet.

    Try this and see if it is close

    Run the macro "InterpolateTimesReturnTemp"

    Hope this helps

    P.S.

    I've added some explanation data to the worksheet to hopefully explain what I mean.

    Attachment updated 16:14(GMT)
    Attached Files Attached Files
    Last edited by Marcol; 05-14-2010 at 11:16 AM. Reason: Further explanation

  3. #3
    Registered User
    Join Date
    04-22-2009
    Location
    Boston
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Interpolate values for different times

    It looks like you interpolated only 22 values instead of 24. I ran the Sub you wrote in the code. I have added little more data on the boundaries.Please have a look at it.
    Thanks a lot.
    Attached Files Attached Files

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Interpolate values for different times

    For a formula approach try this formula in E1 copied down

    =LOOKUP(D1,A$1:A$1142,B$1:B$1142+(B$2:B$1143-B$1:B$1142)*(D1-A$1:A$1142)/(A$2:A$1143-A$1:A$1142))

  5. #5
    Registered User
    Join Date
    04-22-2009
    Location
    Boston
    MS-Off Ver
    Excel 2013
    Posts
    68

    re: Interpolate values for different times

    Thank you sir. I will have to start using Lookup . The function I usually ignore.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    re: Interpolate values for different times

    I have amended the code to use the first and last data in your new data list..

    To allow a check on the table I have added to the code.
    It now transfers the date and temperature as each hour changes.

    I have added DonkeyOtes' formula for comparism,
    Note it will only work if you have already extracted the Date/Time Table.

    The code does this for you in one operation

    Hope you find this is what you require.

    Cheers

    Updated file attached.
    Attached Files Attached Files
    Last edited by Marcol; 05-15-2010 at 07:47 AM. Reason: Added DonkeyOtes' formula for comparism

  7. #7
    Registered User
    Join Date
    04-22-2009
    Location
    Boston
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Interpolate values for different times

    Marcol,
    Thanks for that . I got the answer using one more approach. I converted all the times to epoch times by using datediff function.
    The interpolation is linear. Hence uses a simple formula of

    Y = (X - x1) * (y2 - y1) / (x2 - x1) + y1
    Look for sub Linterp() .

    Converting time to epoch time was useful.
    Attached Files Attached Files

+ 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