+ Reply to Thread
Results 1 to 8 of 8

Replacing Minus Signs on Angles with N/E/S/W Compass Points

  1. #1
    Registered User
    Join Date
    12-17-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    3

    Replacing Minus Signs on Angles with N/E/S/W Compass Points

    Dear Group

    I am in the middle of a large project calculating arc lengths over an ellipsoid earth form in Excel 2010. So far, I have got the macro for the formula in a module based on the Vincenty formula. It is supposed to give me data very accurately. However, for my co-ordinates, it cannot handle minus signs “-“ in front of the data (e.g. for west or south directions).

    My original data is like this in 4 columns:

    Lat1: 10.235145, Long1: -102.256454, Lat2: 56.441134, Long2: 89.5484648

    Now this formula needs me to convert the values to Degrees, Minutes, Seconds.

    I tried using this: =DD2DMS(Degrees), and it gave the following, for example:

    -23.61549186 becomes -23° 36' 55.77''

    However, the formula cannot handle correctly any values with minus signs, so this does not help.

    I need a way to convert an angle from decimal values into Degrees, Minutes, Seconds, WITH a compass sign on the end of each value. E.g.

    -23.61549186 to

    23° 36' 55.77'' S, or
    23~ 36' 55.77'' S

    How can I assign a letter to the end of each co-ordinate value and remove the “-“ signs from the front?

    Can anybody help. I am totally stuck.

    Sincerely

    Keith

  2. #2
    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: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    Can you post the code that implements the Vincenty formula? Somewhere internally, it needs decimal degrees, and converting decimals to DMS so it can be converted back is silly.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-17-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    3

    Re: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    Please Login or Register  to view this content.
    Last edited by Keith360; 12-19-2014 at 07:26 PM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    Hi,

    Unfortunately your post does not comply with Rule 3 of our Forum
    RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    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: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    That function works fine for me right out of the box:

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    Lat1
    Long1
    Lat2
    Long2
    2
    10.23515
    -102.256
    56.44113
    89.54846
    12,534,725
    E2:=distVincenty(A2, B2, C2, D2)
    3
    12,521,410
    E3:=6371000 * CentralAngleV(A2, B2, C2, D2)
    4
    Diff
    0.11%
    E4:=ABS(1-E2/E3)


    EDIT: The CentralAngle function uses the Vincenty formula for the sphere as a confidence check.
    Last edited by shg; 12-19-2014 at 08:04 PM.

  6. #6
    Registered User
    Join Date
    12-17-2014
    Location
    England
    MS-Off Ver
    2010
    Posts
    3

    Re: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    Dear SHG,

    Thank you very much. You have just solved it.

    The same person that used the code in a prepared excel spreadsheet used the following Formula to give the result:

    =distvincenty(signit(B2),signit(C2),signit(B3),signit(C3))


    You used:

    =distvincenty(A1, B1, C1, D1)

    Your formula works. The one they were using in their default template does not work for decimals or with minus figures.

    Thank you for your solution.

  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: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    You're welcome.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Replacing Minus Signs on Angles with N/E/S/W Compass Points

    @ Keith

    Thanks for changing the code tags. shg has reminded me that you are new here and normally I would have changed them for you on this first occasion, but it was late here and I just forgot. Apologies. Have a happy Christmas.

    Cheers

+ 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. Conditional Conditioning Minus signs
    By okopo in forum Excel General
    Replies: 4
    Last Post: 03-22-2012, 05:48 AM
  2. Treating plus and minus signs as text
    By Ross Langmead in forum Excel General
    Replies: 1
    Last Post: 09-30-2009, 03:59 AM
  3. Minus signs after number
    By Crowbar via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2006, 11:20 AM
  4. [SOLVED] MINUS SIGNS REMOVAL
    By Rebecca in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 11-23-2005, 08:10 PM
  5. strip minus signs from right to left
    By Heather in forum Excel General
    Replies: 2
    Last Post: 04-21-2005, 01:06 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