+ Reply to Thread
Results 1 to 10 of 10

Providng range start value and end value where all values are the same

Hybrid View

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Providng range start value and end value where all values are the same

    Hello!
    I am trying to find a way to return a 'start' and 'end' value for a timesheet schedule I am creating. Any ideas would be welcome!

    The values will always be 'like' in column2 if there is a value there at all. In the example, the value is "Mike"
    I want it to reference columns 1 & 2 so that it returns a start time and end time as defined by column1.
    In the example, I want it to return 08:00 - 10:00.
    Alternatively, if I can have it return 08:00 in one cell and 10:00 in another cell.


    07:00
    08:00 Mike
    09:00 Mike
    10:00 Mike
    11:00
    12:00


    Thanks in advance!

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Providng range start value and end value where all values are the same

    hi ejafus, welcome to the forum. assuming your data is from A1:A6, try copying this into a formula bar:
    =TEXT(INDEX(A1:A6,MIN(IF(ISTEXT(B1:B6),ROW(B1:B6)))),"hh:mm")&" "&TEXT(INDEX(A1:A6,MAX(IF(ISTEXT(B1:B6),ROW(B1:B6)))),"hh:mm")
    press CTRL + SHIFT + ENTER to confirm

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Providng range start value and end value where all values are the same

    Thanks! This is fantastic,
    It helped me determine that I have another problem:
    I keep getting the return "15:00" when using just the min or max components of the function you provided.

    It may be because
    - this is the mid-point between the hour schedule (07:00 - 00:00)
    - the results are calculated values from a separate worksheet (ie. A='CW35'!$U9)
    - while text is hidden in the table(using ";;;" formatting), if unhidden, the value "0" appears

    Is there any way to overcome this?

    Also, the max function on its own is not working (#REF!) in this scenario.
    =TEXT(INDEX(A9:A26,MIN(IF(ISTEXT(C9:C26),ROW(C9:C26)))),"hh:mm")&""
    =TEXT(INDEX(A9:A26,MAX(IF(ISTEXT(C9:C26),ROW(C9:C26)))),"hh:mm")&""
    ShowGraphicalView.jpg
    UnhideTextView.jpg

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Providng range start value and end value where all values are the same

    You could put the CSE formulas:

    =MIN(IF((B1:B6="Mike"), A1:A6))
    in one cell (returns 8:00) and

    =MAX(A1:A6*(B1:B6="Mike"))
    in another (returns 10:00)

    both these should be entered with Ctrl-Shift-Enter (Cmd+Return for Mac)
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    09-05-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Providng range start value and end value where all values are the same

    Thanks! That worked.
    Changing status of the thread to solved.
    Thanks to both benishiryo and mikerickson!

    After these statements, I additionally needed to format the cells with these formulas to the custom format hh:mm, and then just supplant the "Mike" with whatever other name I needed to.

    benishiryo -- if you like for interests' sake I can add the sample spreadsheet. Thanks again.

  6. #6
    Registered User
    Join Date
    09-05-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Providng range start value and end value where all values are the same

    ...or...
    I could be a total nut and forgot to properly confirm the 'shift end' times.
    The start times are great,
    and technically the end times work too....except I need them to 'go up to' the next hour, not include the last hour.
    For example, a shift goes from 16:00 to 01:00 -- Each cell with "mike" represents an hour served, so that means I would only put the value "mike" in cells adjacent to 16:00 to 00:00 (midnight).

    I've attached a sample spreadsheet as example.
    ShiftEndSample.xlsx

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Providng range start value and end value where all values are the same

    Take the max value and add 1 hour.

  8. #8
    Registered User
    Join Date
    09-05-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Providng range start value and end value where all values are the same

    Thanks, I was wondering if it is something like that.
    This is what I'm using ...
    =SUM(MAX(IF((C$9:C$27="d"),$A9:$A27))+0.042)

    Is there a better way to do it? This works for those days that have someone scheduled, but adds an hour also to the days that don't have anyone scheduled.
    Last edited by ejafus; 09-06-2012 at 10:22 PM. Reason: Additional info.

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Providng range start value and end value where all values are the same

    You could use a formula like
    =MAX((A1:A6+"1:00:00")*(B1:B6="Mike"))

  10. #10
    Registered User
    Join Date
    09-05-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Providng range start value and end value where all values are the same

    Awesome.

+ 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