+ Reply to Thread
Results 1 to 8 of 8

Formula to check a text string and return maximum and minimum values when condition is met

  1. #1
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Formula to check a text string and return maximum and minimum values when condition is met

    Not really sure how to describe the problem I have.

    I have a set of data with dates and times in column A and values in column B.

    The dates and times columns are in this format: 02.11.2009 09:00:00.000 GMT-0000

    What I'd like is a way to look through each time and date stamp and when it finds 09:00 in the string to return the maximum values from the 07:00, 08:00 and 09:00 rows in column B.

    I have attached an example.

    Thanks,

    Luke
    Attached Files Attached Files

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Formula to check a text string and return maximum and minimum values when condition is

    Quote Originally Posted by lukela85 View Post
    the maximum values from the 07:00, 08:00 and 09:00 rows in column B.
    I don't get this.....

    Could you add expected results in your file, please?
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Formula to check a text string and return maximum and minimum values when condition is

    Hi

    It is easier to do with 'helper' columns.
    In the attached file, formula in column D 'extracts' the 2-digit-Hour vaue from column A using..
    =MID(A1,12,2)*1
    ..the *1 multiples by 1 to convert the extracted text to a numeric value

    Then, in 'helper' column E we use this formula..
    =AND(D1>6,D1<10)*1
    ..to check if the numeric value is between 7 and 9 (i.e. >6 and<10 )
    Formula returns 0 if it isn't between 7 and 9, and returns 1 if it is.

    Then we just use this array-entered formula to get the max value..
    {=MAX(B:B*E:E)}

    see attached updated file

    zeddy
    Excel Timing Protocol Engineer
    Attached Files Attached Files

  4. #4
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Formula to check a text string and return maximum and minimum values when condition is

    If above is correct, instead of zzzeddy's 2 helper's and array formula I suggest:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-20-2009
    Location
    Plymouth, England
    MS-Off Ver
    Excel 2013
    Posts
    149

    Re: Formula to check a text string and return maximum and minimum values when condition is

    Thanks KOKOSEK that works great. I'm not sure if this is the tidiest way to do it but is it possible to have that formula on each row of the sheet but only display the max and min of the 07:00-09:00 period when it reaches 09:00? Maybe with an IF statement? So if it's not 09:00, do nothing but if it is show the max and min? Hope that makes sense.

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Formula to check a text string and return maximum and minimum values when condition is

    Like this:

    A
    B
    C
    10
    03.11.2009 06:00:00.000 GMT-0000
    1.59375
    11
    03.11.2009 07:00:00.000 GMT-0000
    1.59430
    12
    03.11.2009 08:00:00.000 GMT-0000
    1.59440
    13
    03.11.2009 09:00:00.000 GMT-0000
    1.59270
    MAX = 1.5944, MIN = 1.5927
    14
    03.11.2009 10:00:00.000 GMT-0000
    1.58980
    15
    03.11.2009 11:00:00.000 GMT-0000
    1.58740


    Into C1:

    Please Login or Register  to view this content.
    and drag it down.

  7. #7
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Formula to check a text string and return maximum and minimum values when condition is

    Hi

    If the timestamp values are always hourly, (i.e. 1 row per hour) then the entry for 9:00am will be preceded by 2 rows, i.e. for 8:00am and 7:00am.

    You could then use this formula..
    =IF(MID(A3,12,2)="09","MAX: "& MAX(B1:B3)& " ; MIN: " & MIN(B1:B3),"")
    ..starting in cell [C3] and copied down.

    (at 9:00am you are checking the previous 2 rows, so that's why it starts in row 3, to allow for previous 2 rows)

    I added another sample set of values for the following day, so the MAX values show on the 9:00am row etc etc etc
    see attached

    zeddy
    Excel Large Animal Accounting Crew
    Attached Files Attached Files

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Formula to check a text string and return maximum and minimum values when condition is

    Perhaps I am missing something. These return the MAX/MIN at row 13 and 0s for all the others.

    For the maximum try array entering this in cell C1 and fill down

    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    for the minimum array enter in cell D1 and fill down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

+ 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. [SOLVED] Get minimum and maximum with a condition
    By KingTamo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-17-2018, 07:52 AM
  2. [SOLVED] How to get Maximum to Minimum Values using formula
    By rajeshn_in in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2017, 12:16 PM
  3. Replies: 2
    Last Post: 10-03-2014, 03:46 AM
  4. [SOLVED] Value return from Minimum and Maximum values
    By indira in forum Excel General
    Replies: 3
    Last Post: 09-03-2014, 08:37 PM
  5. Help required - formula to check minimum and maximum threshold
    By ismailm in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-18-2014, 08:33 AM
  6. Replies: 5
    Last Post: 11-10-2012, 04:31 PM
  7. Replies: 4
    Last Post: 09-18-2009, 02:09 PM

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