+ Reply to Thread
Results 1 to 6 of 6

Maximum value within a 10 minutes timeframe (conditional maximum)

  1. #1
    Registered User
    Join Date
    12-13-2011
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    5

    Maximum value within a 10 minutes timeframe (conditional maximum)

    Hi, I'm looking for someone who can help me out with a VBA Macro for the following problem.

    There is one column with time running from 3pm to 9pm with the format (hh:mm:ss). Next to it there is a column with numeric values, so that in every row there is a value assigned to a certain point of time.
    Time Value
    05:10:12 201
    05:12:01 212
    05:14:11 207
    05:15:01 209
    05:15:20 220

    I need a macro for the third column that gives out the maximum value within 10 minutes in each row, respectively last 10 minutes.

    In other words there should be a timeframe (counting 10 minutes) and a maximum function within this timeframe.

    Thank You for Your support.

  2. #2
    Valued Forum Contributor
    Join Date
    12-05-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    308

    Re: Maximum value within a 10 minutes timeframe (conditional maximum)

    Hi there.

    This can be done with normal formulae, with no need to resort to macros.

    If I have understood you correctly, you are looking at a window with the reference time at the centre of it, i.e. 5 minutes before or 5 minutes after. If this is not the case, you will need to adjust the +/-TIME command in my formula.

    You can use the MATCH command to determine the range you're interested in, then use OFFSET to refer to it. If your time is in column A, and the value in column B, the formula for column C is:
    Please Login or Register  to view this content.
    You need to have a dummy value outside the first 10minute window at the start of the file to avoid errors for the first couple of rows (I have used 8:00 AM, with a data start time of 8:42 AM). This could be avoided using an ISERROR command, but it starts to look really scary then! Cell C2 then becomes:
    Please Login or Register  to view this content.
    In the attached file I have broken the formula down in to several columns, so you can see what it's doing, then provided a final column with all the parts stitched together.

    Any questions, give me a shout.

    Best regards, Rob.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-13-2011
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Maximum value within a 10 minutes timeframe (conditional maximum)

    At first I would like to thank you very much Rob you helped me a lot.
    I think I wasn't precise enough in my description. I need a time window with the reference time at the end of it, so that only the rows before become relevant (5min before). I guess that makes the formula less complex concerning the iserror comand, which I can hardly reconstruct:-S
    Would you be so kind and help me with this change please?

  4. #4
    Valued Forum Contributor
    Join Date
    12-05-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    308

    Re: Maximum value within a 10 minutes timeframe (conditional maximum)

    Hi Jimmy

    Revised version attached. The formula includes the ISERROR, and checks up to 10 minutes in to the past. The value 10 appears a few times in the formula - change this to change the time window.

    Glad to be of help.

    Feel free to press the Star below.

    Cheers, Rob.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-13-2011
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Maximum value within a 10 minutes timeframe (conditional maximum)

    I have one more question Rob. When defining the starting position of the time window, you typed in +1 in the rows argument of the Offset command. But why? Isn't that one row too much then?

  6. #6
    Registered User
    Join Date
    12-13-2011
    Location
    Paris
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Maximum value within a 10 minutes timeframe (conditional maximum)

    Ok Got it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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