+ Reply to Thread
Results 1 to 21 of 21

Formula automatically rounding up integer

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Formula automatically rounding up integer

    Good Morning all,

    What I am encountering is this, I want to change decimal degrees to DDMMSS. If a cell reads 87.6755, how would I have Excel to read it as 87degrees40min31.8sec? (87:40:31.8)

    Thank you

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula automatically rounding up integer

    Hi and welcome to the forum!

    Can you explain what you mean by "have Excel to read it as"? For the purpose of what? Further calculations? What sort of further calculations will you be performing on this value?

    Or do you mean that you wish to be able to enter 87.6755 in a cell and have a custom number format display it as 87:40:31.8?

    Or do you mean that, say if A1 contains the numeric value 87.6755, you would like e.g. B1 to contain 87:40:31.8, and be content that this value is in text format (since no further calculations will be made with it)?

    Regards
    Last edited by XOR LX; 02-26-2014 at 09:25 AM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Formula automatically rounding up integer

    I did a quick google search and found this:

    http://fieldmuseum.org/users/jon-mar...g-dd-dms-excel
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    Thank you very much for the fast response! If you are up for a challenge, this is my challenge. I have developed a spreadsheet to use as a worksheet for calculating magnitude of inclination and bearing high point. The only calculations I need to complete it is an "IF/THEN" statement that achieves: "if the x value is + and the y value is +, then arctan(y/x), if x value is - and y value is +, then arctan(x/y)+90, if x value is - and y value is -, then arctan(y/x)+180, if x value is + and y value is -, the arctan(x/y)+270. The solution for this I need in DDMMSS format.

    Thanks for your help!

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula automatically rounding up integer

    Perhaps, with your x and y values in A1 and B1 respectively:

    =TEXT(MOD(DEGREES(ATAN((B1/A1)^(-1^((B1*A1)<0))))+LOOKUP(SUMPRODUCT(10^{1,0},SIGN(A1:B1)),{-11,-9,9,11},90*{2,1,3,0}),360)/24,"[hh] mm ss")

    though I can't believe there isn't a better way, mathematically, than first designating into one of your four categories.

    Regards

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula automatically rounding up integer

    See the ATAN2 function.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula automatically rounding up integer

    A
    B
    C
    D
    1
    x
    y
    Angle
    2
    1
    2
    63.43
    C2: =DEGREES(ATAN2(A2, B2))
    3
    -1
    2
    116.57
    4
    1
    -2
    -63.43
    5
    -1
    -2
    -116.57

  8. #8
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    This formula is so close its scary. As a check, I entered 0.0037 as my x value and -0.0255 as my y value. The solution of the formula is 261 44 39.
    The correct solution is I believe is: atan(0.0037/-0.0255)=8.255888715=8 15 21.2(DMS)+270 00 00= 278 15 21.2
    This works out on the Cartesian Graph if my math is correct. I'm adding the 8 15 21.2 to 270 00 00 b/c x value is positive and y value is negative.

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula automatically rounding up integer

    @Bamagadbird

    How do you get atan(0.0037/-0.0255)=8.255888715? Shouldn't that be -8.255888715?

    @shg

    Can't believe I just spent all that time, not even knowing of the existence of that formula!!

    Regards

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula automatically rounding up integer

    Quote Originally Posted by Bamagadbird View Post
    This formula is so close its scary. As a check, I entered 0.0037 as my x value and -0.0255 as my y value. The solution of the formula is 261 44 39
    I dunno how you get that. It's ~ -81.7 degrees, or +278.3.

  11. #11
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    You are correct XOR LX. My over sight, but +278.3 is correct.

    Thanks

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula automatically rounding up integer

    But then your own formula is incorrect if you follow it through, as that too gives 261 44 39.

    I only translated the logic you gave me...

    Regards

  13. #13
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    You may be right...

    Lets see if this makes sense

    (+x,+y) = ATAN(y/x) + 0° This should graph in the I quadrant.
    (-x,+y) = ATAN(x/y) + 90° This should graph in the II quadrant.
    (-x,-y) = ATAN(y/x) + 180° This should graph in the III quadrant.
    (+x,-y = ATAN(x\y) + 270° This should graph in the IV quadrant.

    Does this make better sense?

  14. #14
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    You may be right...

    Lets see if this makes sense

    (+x,+y) = ATAN(y/x) + 0° This should graph in the I quadrant.
    (-x,+y) = ATAN(x/y) + 90° This should graph in the II quadrant.
    (-x,-y) = ATAN(y/x) + 180° This should graph in the III quadrant.
    (+x,-y = ATAN(x\y) + 270° This should graph in the IV quadrant.

    Does this make better sense?

  15. #15
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula automatically rounding up integer

    Those conditions are precisely the same as those you gave originally...

  16. #16
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    I found it pal! This formula works.

    =TEXT(MOD(DEGREES(ATAN((B1/A1)^(-1^((B1*A1)<0))))+LOOKUP(SUMPRODUCT(10^{1,0},SIGN(A1:B1)),{-11,-9,9,11},360*{2,1,3,0}),360)/24,"[hh] mm ss.0")

    Thank you so much for putting me on the right path!

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula automatically rounding up integer

    Wow ...

  18. #18
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Formula automatically rounding up integer

    "Putting you on the right path"??!

    Er, ok. Well, congratulations on your work!

  19. #19
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    Okay, here's the summary of what became of your greatness.

    First, I had to format 4 seperate cells:

    Cell 1:
    =TEXT(MOD(DEGREES(ATAN((G12/F12)^(-1^((G12*F12)<0))))+LOOKUP(SUMPRODUCT(10^{1,0},SIGN(F12:G12)),{-11,-9,9,11},90*{2,1,3,0}),360)/24,"[hh] mm ss.0")

    Cell 2:
    =TEXT(MOD(DEGREES(ATAN((F12/G12)^(-1^((F12*G12)<0))))+LOOKUP(SUMPRODUCT(10^{1,0},SIGN(F12:G12)),{-11,-9,9,11},180*{2,1,3,0}),360)/24,"[hh] mm ss.0")

    Cell 3:
    =TEXT(MOD(DEGREES(ATAN((G12/F12)^(-1^((G12*F12)<0))))+LOOKUP(SUMPRODUCT(10^{1,0},SIGN(F12:G12)),{-11,-9,9,11},270*{2,1,3,0}),360)/24,"[hh] mm ss.0")

    Cell 4:
    =TEXT(MOD(DEGREES(ATAN((F12/G12)^(-1^((F12*G12)<0))))+LOOKUP(SUMPRODUCT(10^{1,0},SIGN(F12:G12)),{-11,-9,9,11},360*{2,1,3,0}),360)/24,"[hh] mm ss.0")

    Then I had to format a cell with the IF,Then,And statement:

    =IF(AND(F12>=0,G12>=0),A19,IF(AND(F12<0,G12>=0),B19,IF(AND(F12<0,G12<0),C19,IF(AND(F12>=0,G12<0),D19))))

    This achieved my final goal.

    Thanks Guys!!

  20. #20
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Formula automatically rounding up integer

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

    It is also customary to click on the Add reputation button of those that helped you as a nice way of saying thank you to them.

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula automatically rounding up integer

    Using =degrees(atan2(a1, b1)) instead of all that was too complicated?

  22. #22
    Registered User
    Join Date
    02-26-2014
    Location
    Mobile, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula automatically rounding up integer

    how do you convert this to DMS? This appears to be very simple. The formulae I reflected back resulting from the input given by XOR LX works flawlessly in the worksheet I developed for our survey process, but I have a use for =degrees(atan2(a1, b1)) in another task ahead of me.

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula automatically rounding up integer

    A
    B
    C
    D
    1
    x
    y
    Angle dec
    2
    1
    2
    63.43495
    C2: =DEGREES(ATAN2(A2, B2))
    3
    -1
    2
    116.56505
    Format of C2: 0.00000
    4
    1
    -2
    -63.43495
    5
    -1
    -2
    -116.56505
    6
    7
    x
    y
    Angle DMS
    8
    1
    2
    63:26:05.8
    C7: =MOD(DEGREES(ATAN2(A7, B7)), 360) / 24
    9
    -1
    2
    116:33:54.2
    Format of C7: [h]:mm:ss.0
    10
    1
    -2
    296:33:54.2
    11
    -1
    -2
    243:26:05.8
    Last edited by shg; 03-03-2014 at 06:17 PM.

+ 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. Rounding to a specific integer using formulas
    By doug@bunchesofbows in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2012, 12:31 PM
  2. Count the number of occurrences of an integer withing a larger integer
    By nnktran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2010, 01:04 PM
  3. [SOLVED] automatically rounding
    By tmodso in forum Excel General
    Replies: 2
    Last Post: 06-12-2006, 12:35 PM
  4. help with rounding up to whole integer
    By kjcramp in forum Excel General
    Replies: 3
    Last Post: 04-10-2006, 02:10 PM
  5. Rounding to nearest integer
    By pattyh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-01-2005, 03:24 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