+ Reply to Thread
Results 1 to 6 of 6

Making ranges based on variable data

  1. #1
    Registered User
    Join Date
    09-25-2018
    Location
    Pakistan
    MS-Off Ver
    2017
    Posts
    2

    Making ranges based on variable data

    Hi All,

    I am stuck with a problem for 2 days and I can not find a solution to it. I am trying to make an employee roster with variable constraints. Each employee will get a rest day after 5 days provided the 6th day is not Friday or Sunday. If the 6th day is Friday or Sunday, the employee gets a day off after 4 days (a day before Friday or Sunday).

    =IF(COUNTIF($C$3:C3,"5:15")<4,"5:15",IF(COUNTIF($C$3:C3,"5:15")=4,IF(OR(E2="Friday",E2="Sunday"),"R","5:15"),IF(COUNTIF($C$3:C3,"5:15")=5,IF(OR(E2="Friday",E2="Sunday"),"R","5:15"))))

    I have managed to get this far but I need the range to change after "Rest" appears in the schedule. In my current formula, the range keeps expanding from C3 onwards and the numerical counter does not work. Is there a way that I can keep the range variable i.e. If previous cell (G3) = Rest, the range of the formula should change to the Rest cell onwards ($G$3:G3).

    Would be really great if someone has some other way to do this as well!

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Making ranges based on variable data

    b4 =IF(OR(AND(COUNTIF(INDEX(B:B,AGGREGATE(14,6,ROW($A$1:$A3)/(B$1:B3="r"),1)):B3,"o")=5,OR(WEEKDAY($A4,2)<>5,WEEKDAY($A4,2)<>7)),AND(COUNTIF(INDEX(B:B,AGGREGATE(14,6,ROW($A$1:$A3)/(B$1:B3="r"),1)):B3,"o")=4,OR(WEEKDAY($A4,2)=5,WEEKDAY($A3,2)=7))),"r","o")
    in b3 - r
    in A:A dates
    Attached Files Attached Files
    Last edited by tim201110; 09-25-2018 at 04:26 AM.

  3. #3
    Registered User
    Join Date
    09-25-2018
    Location
    Pakistan
    MS-Off Ver
    2017
    Posts
    2

    Re: Making ranges based on variable data

    Thanks Tim.

    Couple of questions:

    1. The formula is still showing the rest day on a Sunday. I need no rests on Sunday and Friday.

    2. I am attaching the sheet I am working on. Can you review and help out?
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-28-2015
    Location
    TX, USA
    MS-Off Ver
    2013
    Posts
    69

    Re: Making ranges based on variable data

    You might try putting the Non-Rest days condition at the front of the code.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Making ranges based on variable data

    small error
    =IF(OR(AND(COUNTIF(INDEX(B:B,AGGREGATE(14,6,ROW($A$1:$A3)/(B$1:B3="r"),1)):B3,"o")=5,WEEKDAY($A4,2)<>5,WEEKDAY($A4,2)<>7),AND(COUNTIF(INDEX(B:B,AGGREGATE(14,6,ROW($A$1:$A3)/(B$1:B3="r"),1)):B3,"o")=4,OR(WEEKDAY($A4,2)=4,WEEKDAY($A4,2)=6))),"r","o")

  6. #6
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Making ranges based on variable data

    a shorter one
    =IF(CHOOSE(COUNTIF(INDEX(B:B,AGGREGATE(14,6,ROW($A$1:$A3)/(B$1:B3="r"),1)):B3,"o")+1,,,,,5,6)+CHOOSE(WEEKDAY($A4,2),1,1,1,2,,2,)>=7,"r","o")

+ 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] New variable based on multiple date ranges - nested ifs?
    By Vestlink in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-20-2016, 03:22 AM
  2. Copy data to different, variable ranges.
    By Penfoldthethird in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2016, 11:49 AM
  3. [SOLVED] Assign different named ranges based on variable number of entries
    By BrotherNeptune in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-17-2015, 10:15 AM
  4. Replies: 3
    Last Post: 02-20-2011, 06:30 AM
  5. Variable Data Ranges
    By haironfire in forum Excel General
    Replies: 2
    Last Post: 11-18-2006, 05:54 AM
  6. Counting variable ranges and auto-summing variable ranges
    By Father Guido in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2006, 11:10 PM
  7. Replies: 0
    Last Post: 04-21-2005, 06:40 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