+ Reply to Thread
Results 1 to 11 of 11

Time series function

  1. #1
    Registered User
    Join Date
    03-26-2008
    Posts
    15

    Time series function

    I'm trying to calculate and average using a time frame in the day. I want to use a certain number "X" that correlates to a hour/minute in the current time. How do I write a statement to get me the correct "X" value?

    example:


    8:00 .005
    8:01 .006
    8:02 .0075
    8:03 .0077
    8:04 .008

    time now is 8:03

    How do I get the .0077 in excel?

    thx

  2. #2
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    199
    For your post this formula would work to return .0077:

    =VLOOKUP(A4,A1:B5,2,FALSE)

    However, there are a few questions...where is the time coming from? Do you have that pasted in a cell in a "=NOW()" function, is it returned from another cell, or do you just want to enter it in a cell and use that as a reference for the formula?

    In the formula posted above I used A4 as the reference as that cell corresponds with "8:03" and therefore returns the correct value. But I am imagining that there is more to your sheet than that.

    Can you provide a little more information?

  3. #3
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    I don't know how to get a clock in there.

    I want it so that what ever time it is, by hour/minute, it finds the matching hour/minute and uses the variable in the next cell over from it so that I can make an average from another inputed field from past days to make a calculate average.

  4. #4
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    199
    To get the exact date and time in a specific cell you can use the NOW formula:

    =NOW()

    Only one problem with that formula is that it stays static until you recalculate. To get around that you can invoke this code in your workbook to show an actual date and time (running)

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    Do I put that in the macro area? Also I don't need the date, just time.

  6. #6
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    199
    Yes, you would add that in as code on your specific sheet. You can take out the date portion and just use this poriton of the code that will place the current time in A1.

    Please Login or Register  to view this content.
    Hope that helps.

  7. #7
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    I'll try to make it work tomorrow.

  8. #8
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    Do I put it in the Visual Basic editor? And it should work from cut n pasting it?

  9. #9
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    199
    Yes, if you have the workbook open, press ALT + F11 and it will open up. Right click on "This Workbook" for your code and go Insert > Module. Then paste the code into the workbook and save. To start the clock running just press ALT + F8 and run the "RECALC" macro. The current time should appear in A1.

    Hope that helps.

  10. #10
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    thx alots. I really appreciated it. The clock works and my ave works real time to the mintute.

    thx.

  11. #11
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    199
    schlepers,

    I am glad that the solution worked for you. Thanks for the feedback.

+ 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