Microsoft Excel VBA question: Converting decimal degrees to degrees-minutes-seconds (DMS), with rounding customization.
I'm pretty proficient with Excel but am a complete n00b when it comes to programming even Visual Basic. I needed to convert some decimal degrees into DMS format, and failing to find a function that did so, I went to Google and found
this page. Surprisingly enough, both of those modules worked successfully, allowing me to access them through the Function menu. I was even able to figure out how to change the function name to something I find clearer.
My one gripe about the Decimal-to-DMS conversion is that it doesn't allow for any numbers after the decimal point in the Seconds part of the output. I wouldn't usually mind (I know how tiny a second is), but I'm using this for a mapping application where meters matter, and the rounding is throwing me off. Can the hive mind help me get decimal seconds?
Seconds = Format(((Minutes - Int(Minutes)) * 60), "0")
to:
Seconds = Format(((Minutes - Int(Minutes)) * 60), "0.00000")
(my emph...)
That'll give you five decimal places of seconds.
posted by pompomtom at 4:07 PM on June 10, 2008