+ Reply to Thread
Results 1 to 14 of 14

How to add offset to my formula?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-29-2013
    Location
    Pattaya, Thailand
    MS-Off Ver
    Excel 2013
    Posts
    71

    Question How to add offset to my formula?

    I'm using a formula that checks if a day falls between 2 dates that is listed in another sheet.
    These dates are listed in 2 columns: B and C
    The dates run down 10 rows each time, after which a 5 row break is in place before the next sequence begins

    The problem is that I can't drag my formula down the normal way, because it just adds +1 row.
    I've read about using "OFFSET", but I can't figure out how to add this to my formula.
    In my case the next row should add "+14" to all values in B and C column.

    The formula I'm using is:

    Formula: copy to clipboard
    =IF(OR(C$3=MEDIAN(C$3,Dates!$B6:$C6),C$3=MEDIAN(C$3,Dates!$B7:$C7),C$3=MEDIAN(C$3,Dates!$B8:$C8),C$3=MEDIAN(C$3,Dates!$B9:$C9),C$3=MEDIAN(C$3,Dates!$B10:$C10),C$3=MEDIAN(C$3,Dates!$B11:$C11),C$3=MEDIAN(C$3,Dates!$B12:$C12),C$3=MEDIAN(C$3,Dates!$B13:$C13),C$3=MEDIAN(C$3,Dates!$B14:$C14),C$3=MEDIAN(C$3,Dates!$B15:$C15)),1,0)


    The formula on the following row should be:

    Formula: copy to clipboard
    =IF(OR(C$3=MEDIAN(C$3,Dates!$B20:$C20),C$3=MEDIAN(C$3,Dates!$B21:$C21),C$3=MEDIAN(C$3,Dates!$B22:$C22),C$3=MEDIAN(C$3,Dates!$B23:$C23),C$3=MEDIAN(C$3,Dates!$B24:$C24),C$3=MEDIAN(C$3,Dates!$B25:$C25),C$3=MEDIAN(C$3,Dates!$B26:$C26),C$3=MEDIAN(C$3,Dates!$B27:$C27),C$3=MEDIAN(C$3,Dates!$B28:$C28),C$3=MEDIAN(C$3,Dates!$B29:$C29)),1,0)



    I've attached an example with what I would like to accomplish. I just don't want to manually change all the formulas all the way down 135 rows.

    Any help is much appreciated.
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How to add offset to my formula?

    Would this help?

    Formula: copy to clipboard
    =--(SUMPRODUCT((OFFSET(Dates!$B$6,14,0,10)<=$E$4)*(OFFSET(Dates!$B$6,14,1,10)>=$E$4))>0)


    Change red number to desired section (0 for first, 14 for second, 28 for third... Or put somewhere reference like A1 and change only A1 value)

  3. #3
    Registered User
    Join Date
    11-29-2013
    Location
    Pattaya, Thailand
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: How to add offset to my formula?

    Hello Zbor,

    Sorry mate, If I use that formula instead of the other one, the result isn't correct. (all dates light up green)

    Basically I'm using the columns in sheet "Total" as individual days. so that's 7 x 365 days (year 2013 -2020)
    Each column represents 1 day; I've narrowed them down to 1px to get a nice overview.

    the formula is entered under each day, and checks if that day falls between 2 dates on the other sheet.
    if it does, it returns 1, if it doesn't, it returns 0. I'm using Conditional Formatting to replace the 1 for a green color.

    If you can, then please play around with the dates and you'll see what happens on the "Total" sheet.

    I'm more than happy if you know of another formula that does the same as what I'm trying to get now, but the only way I see it is by changing the numbers in the formula as it is.

    Cheers,

    Michael.

  4. #4
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: How to add offset to my formula?

    HTML Code: 
    Try above in C4 as you drag down formula it will increment by 14 rows
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  5. #5
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: How to add offset to my formula?

    Hello You could use
    for B6:C6 INDIRECT("Dates!$B"&((ROW(A6)-ROW($A$6))*14)+6&":"&"$C"&((ROW(A6)-ROW($A$6))*14)+6) to get dates!$B6:$C6
    for B7:C7 INDIRECT("Dates!$B"&((ROW(A7)-ROW($A$7))*14)+6&":"&"$C"&((ROW(A7)-ROW($A$7))*14)+6) to get dates!$B7:$C7
    for B7:C7 INDIRECT("Dates!$B"&((ROW(A8)-ROW($A$8))*14)+6&":"&"$C"&((ROW(A8)-ROW($A$8))*14)+6) to get dates!$B8:$C8
    and so on
    when you drag down each will be incremented by your desired number

  6. #6
    Registered User
    Join Date
    11-29-2013
    Location
    Pattaya, Thailand
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: How to add offset to my formula?

    I'm terribly sorry, but I fail to comprehend where to use that bit...

    Do I include it in the current formula or is it meant to replace it?

    If you don't mind, ideally it makes the most sense if you could enter it as a working example to the sheet I uploaded.
    I understand it's a bit more effort, but I would highly appreciate it.

    Cheers,

    Michael.

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How to add offset to my formula?

    uops, my mistake.. Try now:


    Formula: copy to clipboard
    =--(SUMPRODUCT((OFFSET(Dates!$B$6,14,0,10)<=$C3)*(OFFSET(Dates!$B$6,14,1,10)>=$C3))>0)


    If you want automatically for 14 rows:

    Formula: copy to clipboard
    =--(SUMPRODUCT((OFFSET(Dates!$B$6,14*(ROW(A1)-1),0,10)<=$C3)*(OFFSET(Dates!$B$6,14*(ROW(A1)-1),1,10)>=$C3))>0)
    Last edited by zbor; 03-05-2014 at 07:12 AM.

  8. #8
    Registered User
    Join Date
    11-29-2013
    Location
    Pattaya, Thailand
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: How to add offset to my formula?

    I'll give it a shot in an hour or so. It seems we cross-posted some replies. It's 18:00 here now and I need to leave the office. I'll check it out after dinner and come back to you with the results.

    Thanks,

    Michael.

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,825

    Re: How to add offset to my formula?

    I've inserted a new column A in the Total sheet, and used that for the reference code that you have in column A of the Dates sheet. Then the formula in D4 (was C4) can be changed to this:

    Formula: copy to clipboard
    =IF(SUMPRODUCT((D$3>=INDIRECT("Dates!$B"&MATCH($A4,Dates!$A:$A,0)+3&":$B"&MATCH($A4,Dates!$A:$A,0)+12))*(D$3<=INDIRECT("Dates!$C"&MATCH($A4,Dates!$A:$A,0)+3&":$C"&MATCH($A4,Dates!$A:$A,0)+12))),1,0)


    which can then be copied across and down as required. You can simplify it further by having this in C4:

    Formula: copy to clipboard
    =IFERROR(IF(A4="","",MATCH($A4,Dates!$A:$A,0)),"")


    (coloured white, so you don't see it), then you can have this in D4:

    Formula: copy to clipboard
    =IFERROR(IF(SUMPRODUCT((D$3>=INDIRECT("Dates!$B"&$C4+3&":$B"&$C4+12))*(D$3<=INDIRECT("Dates!$C"&$C4+3&":$C"&$C4+12))),1,0),0)

    I've copied this across and then down to row 20 in the attached workbook, to show it working.

    Hope this helps.

    Pete
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,628

    Re: How to add offset to my formula?

    Insted of this
    =IF(OR(C$3=MEDIAN(C$3,Dates!$B6:$C6),C$3=MEDIAN(C$3,Dates!$B7:$C7),C$3=MEDIAN(C$3,Dates!$B8:$C8),C$3=MEDIAN(C$3,Dates!$B9:$C9),C$3=MEDIAN(C$3,Dates!$B10:$C10),C$3=MEDIAN(C$3,Dates!$B11:$C11),C$3=MEDIAN(C$3,Dates!$B12:$C12),C$3=MEDIAN(C$3,Dates!$B13:$C13),C$3=MEDIAN(C$3,Dates!$B14:$C14),C$3=MEDIAN(C$3,Dates!$B15:$C15)),1,0)
    Try this
    =IF(OR(PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$6:$C$6,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$7:$C$7,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$8:$C$8,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$9:$C$9,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$10:$C$10,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$11:$C$11,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$12:$C$12,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$13:$C$13,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$14:$C$14,(ROW(A1)-1)*14,)),PL$3=MEDIAN(PL$3,OFFSET(Dates!$B$15:$C$15,(ROW(A1)-1)*14,))),1,0)
    Then drag down.

  11. #11
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: How to add offset to my formula?

    Ignore my above post, I've fix it now to real example:

    Formula: copy to clipboard
    =--(SUMPRODUCT((OFFSET(Dates!$B$6,14*(ROWS($C$4:$C4)-1),0,10)<=C$3)*(OFFSET(Dates!$B$6,14*(ROWS($C$4:$C4)-1),1,10)>=C$3))>0)
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-29-2013
    Location
    Pattaya, Thailand
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: How to add offset to my formula?

    I would really like to thank everyone who has contributed to solve my problem/question. Since I had the luxury of picking from several solutions that were provided, I ended up going with Pete's solution as it also skips the empty rows automatically between the groups of properties by using a "MATCH" in column C. Everyone's help and support is greatly appreciated, and excelforum is one of the best forums around in my opinion. The response-time and quality of the answers provided by its members is absolutely outstanding.

    You have all been thanked personally as well, and I hope to be helpful for someone some day too.

    Cheers,

    Michael.

  13. #13
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: How to add offset to my formula?

    Thanks for the Feedback!

  14. #14
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,825

    Re: How to add offset to my formula?

    Yes, thank you for the kind words, Michael.

    Pete

+ 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. Please Help with offset formula.
    By balois in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 04-02-2013, 05:28 AM
  2. function similar to offset to offset the offset
    By Jerseynjphillypa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2012, 03:07 PM
  3. Reformatting - insert formula with offset, then offset to next cell
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2011, 05:41 AM
  4. Replies: 2
    Last Post: 10-08-2009, 09:51 PM
  5. Replies: 2
    Last Post: 01-03-2006, 05:42 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