+ Reply to Thread
Results 1 to 13 of 13

Calculate Date Difference

Hybrid View

AnanthakrishnanK Calculate Date Difference 04-20-2009, 03:13 AM
zbor Re: Calculate Date Difference 04-20-2009, 03:28 AM
JBeaucaire Re: Calculate Date Difference 04-20-2009, 03:30 AM
zbor Re: Calculate Date Difference 04-20-2009, 03:34 AM
JONvdHeyden Re: Calculate Date Difference 04-20-2009, 03:45 AM
zbor Re: Calculate Date Difference 04-20-2009, 03:55 AM
JONvdHeyden Re: Calculate Date Difference 04-20-2009, 03:57 AM
zbor Re: Calculate Date Difference 04-20-2009, 04:09 AM
JBeaucaire Re: Calculate Date Difference 04-20-2009, 04:20 AM
zbor Re: Calculate Date Difference 04-20-2009, 04:27 AM
JBeaucaire Re: Calculate Date Difference 04-20-2009, 04:47 AM
JONvdHeyden Re: Calculate Date Difference 04-20-2009, 04:52 AM
zbor Re: Calculate Date Difference 04-20-2009, 04:55 AM
  1. #1
    Registered User
    Join Date
    04-19-2009
    Location
    Dubai
    MS-Off Ver
    Excel 2003
    Posts
    8

    Calculate Date Difference

    Hi Dears,
    I request a help:
    A1 = 01-Apr-2009
    B1 = 02-Apr-2009
    C1 = 03-Apr-2009
    D1 = Blank
    E1 = 05-Apr-2009
    F1 = 06-Apr-2009

    What is the best suitable formula to find "First blank cell", then "date difference" between today and its previous cell's (i.e today minus "C1" in this case).

    Thanks & Best regards,
    Ananthakrishnan.K
    Last edited by AnanthakrishnanK; 04-20-2009 at 05:42 AM.

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

    Re: Calculate Date Difference

    You can use macro (maybe even you don't...) to do that... this is my solution without macro...

    If it's really blank...
    Add aditional column...
    Write: =IF(ISBLANK(F1);0;F1) and extend to whole array

    Then your solution is:

    =TODAY()-INDEX(G1:G11;MATCH(0;G1:G11;0)-1;1)
    (I assume first value of array is date...)
    Never use Merged Cells in Excel

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculate Date Difference

    Enter this array formula:

    =TODAY()-INDIRECT(ADDRESS(1,MATCH(TRUE,ISBLANK(A1:F1),0)-1))

    ..and confirm with CTRL-SHIFT-ENTER to activate the array. If you do that, the answer 17 should appear. If you get an error, MAKE SURE D1 is really EMPTY (blank), then enter that formula again with CTRL-SHIFT-ENTER.

    BTW, I wouldn't use a LOT of these array formulas, but for a small data set it's fine. If you have 1000s of rows to deal with, using the added helper ROW (not column) suggested by zbor is the way to go.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,033

    Re: Calculate Date Difference

    Yes, sorry, since I copy pasted it I dealed with columns

  5. #5
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculate Date Difference

    Or similar to method shown by JBeaucaire:

    =TODAY()-INDEX(A1:A6,MATCH(TRUE,ISBLANK(A1:A6),0)-1)

    also confirmed with Control+Shift+Enter
    Regards

    Jon (Excel 2003, 2007, 2010, 2013)

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,033

    Re: Calculate Date Difference

    I try myself with INDEX-MATCH apporach but I keep getting #N/A error...

    And now with both above formulas (regardless of ctrl+shift+enter)...

  7. #7
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculate Date Difference

    Perhaps your blank is no longer a true blank, what happends if you use:

    =TODAY()-INDEX(A1:A6,MATCH("",A1:A6,0)-1)

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,033

    Re: Calculate Date Difference

    Same :-S

    It is true blank since I've deleted those cells

    Book1.xlsx

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculate Date Difference

    Put into the right format, our formulas work fine.
    Attached Files Attached Files

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

    Re: Calculate Date Difference

    Works.. Thx.. Nice job obth of you!

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculate Date Difference

    If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED]

  12. #12
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: Calculate Date Difference

    Further, you can highlight the range that contains the date. Go to find + replace (CTRL+H), leave the find box empty, replace with ="". Hit replace all. That will change the blank cells such that they are not true blanks. The you can use:

    =TODAY()-INDEX(A1:A6,MATCH("",A1:A6,0)-1)

    Which does not have to be CSE entered and should be somewhat more efficient than any array formula method used.

  13. #13
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,033

    Re: Calculate Date Difference

    I also find that solution but then I assume that dates might be entered manually so I thought this up might be better but I write If it's really blank... just in case that user can adopt formula without inserting new row in case there is something as =""

+ 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