+ Reply to Thread
Results 1 to 27 of 27

Difference between 2 cells

  1. #1
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Difference between 2 cells

    Hi,
    Can be made these differences?

    B6 = 41 anno/i - 4 mese/i (41 years / 4 month)
    B7 = 42 anni - 6 mesi (42 years - 6 month)

    The result in B8.
    I attach the example.
    max_max
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,820

    Re: Difference between 2 cells

    As given, I see a 2 to 3 step procedure:

    1) Convert text to number
    2) Compute difference of number
    3) Convert number back to text (if needed).

    As one who avoids text operations as much as possible, steps 1 and 3 are the difficult ones, and I would do anything I could to avoid them. My first question back to you is -- is it absolutely essential to this project to have the inputs and outputs in these text formats?

    If not, I would enter the values in some real number format. I could see using a yy.mm type format (and use the DOLLARDE() and DOLLARFR() functions) or entering them as fractions (yy mm/12). With the values entered as numbers, then the difference is a simple subtraction formula.

    option 1: =DOLLARFR(DOLLARDE(41.04,12)-DOLLARDE(42.06,12),12) would return 1.02 (meaning 1 year and 2 months). 41.04 and 42.06 could be entered in B6 and B7 and references used.
    option 2: Enter 41 4/12 and 42 6/12 into B6 and B7. B8 is simply =B7-B6. Format all cells as 0 0/12 to get the y m/12 display.

    Are either of those workable options, or is it absolutely essential to deal with the text values given in your sample sheet?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    430 = 43 anni (43 year)
    4211 = 42 anni 11 mese (42 year 11 mouth)

    risultato = 0 anni - 1 mese
    Result = 0 years - 1 month

    -------------------------

    450 = 45 anni
    4211 = 42 anni 11 mese

    risultato = 2 anni - 1 mese

    -------------------------

    438 = 43 anni 8 mesi
    4211 = 42 anni 11 mese

    risultato = 0 anni - 9 mese
    Last edited by max_max; 07-22-2017 at 07:24 AM.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    One way (a bit of a monster!!

    =INT(LEFT(B7,SEARCH(" ",B7)-1)+MID(TRIM(B7),SEARCH("-",TRIM(B7))+1,3)/12-(LEFT(B6,SEARCH(" ",B6)-1)+MID(TRIM(B6),SEARCH("-",TRIM(B6))+1,3)/12))&" anno/I - "&ROUND(12*MOD(LEFT(B7,SEARCH(" ",B7)-1)+MID(TRIM(B7),SEARCH("-",TRIM(B7))+1,3)/12-(LEFT(B6,SEARCH(" ",B6)-1)+MID(TRIM(B6),SEARCH("-",TRIM(B6))+1,3)/12),1),0)&" mese/I"
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,820

    Re: Difference between 2 cells

    430 = 43 anni (43 year)
    4211 = 42 anni 11 mese (42 year 11 mouth)
    If I were going to use these integer representations, I would make them all 4 digit instead of a mix of 3 and 4 digit, and do something very similar to the first option (using the DOLLARDE() and DOLLARFR() functions)

    4300 = 43 year
    4211=42 year 11 month
    =DOLLARFR(DOLLARDE(4300/100,12)-DOLLARDE(4211/100,12),12)*100 which would return 0001 (if formatted as "0000")

    By making all entries 4 digit, you always divide/multiply by 100. With a mix of 3 and 4 digit integers, you need a test to determine whether to divide/multiply by 10, and you will run into extra trouble with the ambiguity of 1 month or 10 month (will 43.1 mean 43 years 1 month or 43 years 10 months. With a 4 digit representation, you don't have that ambiguity).

    Glenn Kennedy put together that monster text based formula, so maybe you will prefer that approach on the original text representation?

  6. #6
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Hi to all.

    Gleen Kennedy your formula it's o.k.

    Mrshorty's too complicated your solution, I can not translate into proper Italian.

    Thank you to all.
    max_max
    Last edited by max_max; 07-22-2017 at 12:16 PM.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  8. #8
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Hello mr gleen kennedy.
    Is it possible to modify your formula?
    In the attached file, you must do this:

    in B10 = (B1 + B8)-B6
    new date is?

    The date in B1 is in format European " day / month / year"

    I thank you in advance.
    max_max
    Attached Files Attached Files
    Last edited by max_max; 07-24-2017 at 03:06 PM.

  9. #9
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Sorry I forgot that in the table in column G there is also an empty line.
    I attach the new example.
    max_max
    Attached Files Attached Files

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,552

    Re: Difference between 2 cells

    This proposed solution employs Mr. Shorty's suggestion (I hope correctly) and three helper cells (C6, C8 and C10) which may be hidden for aesthetic purposes.
    The formula for C6 and C8 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The formula for C10 is Mr. Shorty's:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The formula for B10 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Since your profile states that you are using Excel 2007 I am attaching the file as an .xlsx
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    Using my monster..
    Attached Files Attached Files

  12. #12
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Thanks you gleen and jetemc, your formulas work
    max_max

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  14. #14
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Ops glen kennedy your formula if a cell G5:G13 is empty error #VALUE
    max_max

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    Really? Very odd, since it doesn't reference G5:G13....
    Attached Files Attached Files

  16. #16
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Look at the picture
    Attached Images Attached Images

  17. #17
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    Ahhh.. You said if G5:G13 was blank, whereas you meant B6...

  18. #18
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    Try it now...
    Attached Files Attached Files

  19. #19
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Hello gleen is ok now.
    A greeting.
    max_max

  20. #20
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    GREAT!!

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  21. #21
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Hi Gleen Kennedy,
    I saw a mistake.
    Example:

    B1 = 06/06/1980
    B6 = 18 anno/i - 10 mese/i
    B8 = 45 anni - 0 mesi

    result in B10 = 01/08/2006 (error)

    exact is 06/08/2006

    max_max

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Difference between 2 cells

    Max_max - could you please explain how this thread is really any different to the other one? The purpose seems to be essentially the same - is it?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  23. #23
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Who, not really.
    This thread the formula finds a difference between 2/3 dates
    The other finds the days / month / years between 2 dates
    max_max

  24. #24
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    I never adjusted the days, as the other bits were years and months...

    Use:

    DATE(YEAR(B1)+INT(LEFT(B8,SEARCH(" ",B8)-1)+MID(TRIM(B8),SEARCH("-",TRIM(B8))+1,3)/12-IF(B6="",0,(LEFT(B6,SEARCH(" ",B6)-1)+MID(TRIM(B6),SEARCH("-",TRIM(B6))+1,3)/12))),MONTH(B1)+ROUND(12*MOD(LEFT(B8,SEARCH(" ",B8)-1)+MID(TRIM(B8),SEARCH("-",TRIM(B8))+1,3)/12-IF(B6="",0,(LEFT(B6,SEARCH(" ",B6)-1)+MID(TRIM(B6),SEARCH("-",TRIM(B6))+1,3)/12)),1),0),DAY(B1))

    instead of

    DATE(YEAR(B1)+INT(LEFT(B8,SEARCH(" ",B8)-1)+MID(TRIM(B8),SEARCH("-",TRIM(B8))+1,3)/12-IF(B6="",0,(LEFT(B6,SEARCH(" ",B6)-1)+MID(TRIM(B6),SEARCH("-",TRIM(B6))+1,3)/12))),MONTH(B1)+ROUND(12*MOD(LEFT(B8,SEARCH(" ",B8)-1)+MID(TRIM(B8),SEARCH("-",TRIM(B8))+1,3)/12-IF(B6="",0,(LEFT(B6,SEARCH(" ",B6)-1)+MID(TRIM(B6),SEARCH("-",TRIM(B6))+1,3)/12)),1),0),1)

  25. #25
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Difference between 2 cells

    Hi gleen seems to me right now.
    Your formula in Italian is:

    =DATA(ANNO(B1)+INT(SINISTRA(B8;RICERCA(" ";B8)-1)+STRINGA.ESTRAI(ANNULLA.SPAZI(B8);RICERCA("-";ANNULLA.SPAZI(B8))+1;3)/12-SE(B6="";0;(SINISTRA(B6;RICERCA(" ";B6)-1)
    +STRINGA.ESTRAI(ANNULLA.SPAZI(B6);RICERCA("-";ANNULLA.SPAZI(B6))+1;3)/12)));MESE(B1)+ARROTONDA(12*RESTO(SINISTRA(B8;RICERCA(" ";B8)-1)
    +STRINGA.ESTRAI(ANNULLA.SPAZI(B8);RICERCA("-";ANNULLA.SPAZI(B8))+1;3)/12-SE(B6="";0;(SINISTRA(B6;RICERCA(" ";B6)-1)+STRINGA.ESTRAI(ANNULLA.SPAZI(B6);RICERCA("-";ANNULLA.SPAZI(B6))+1;3)/12));1);0);GIORNO(B1))

    Thank you.
    max_max

  26. #26
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Difference between 2 cells

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

  27. #27
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Difference between 2 cells

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] To check the position of a word in a range of cells & to get difference between the cells
    By KARTHICKNAIDU in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-03-2016, 09:07 AM
  2. Difference between the cells!
    By merko30 in forum Excel General
    Replies: 2
    Last Post: 06-28-2016, 11:30 PM
  3. Difference in cells
    By drosew in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-11-2016, 08:37 PM
  4. Cant find how to get average dates difference between averaged cells, w/out extra cells
    By jeremyharrisonspo in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-10-2014, 08:20 PM
  5. fomatting cells based on difference between values of cells two ranges.
    By KATIEexcel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2013, 04:08 AM
  6. [SOLVED] Formular to calculate difference between cells if cells in a range are the same
    By CharlieZangel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2012, 04:41 PM
  7. [SOLVED] Difference between Cells
    By Jim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-27-2005, 09:05 AM

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