Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi there folks.
I am trying to format Degrees expressed as a decimal amount as Degrees Minutes Seconds The [h]:mm:ss format given in the custom section of the "Format Cells" dialogue box does only a tolerable job and I need to divide the Decimal Degrees by 24 first, in order to achieve that. So... in order to achieve my goal I have decided to write my own UDF. Although this does not leave me with an underlying numeric value, (and that is not a real bad thing) I cannot discover a way to insert a ° (°)character into the output string. The function code is as follows: Function formDMS(DecDeg) If DecDeg < 0 Then DecDeg = DecDeg * (-1) d = Int(DecDeg) m = (DecDeg - d) * 60 im = Int(m) s = Round((m - Int(m)) * 60, 0) formDMS = d & ":" & im & "'" & s & """" End Function ---------------^------------------------ it is the character above the "^" that needs to be modified. any ideas... would be appreciated Regards Geoff |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
formDMS = d & Chr(&HB0) & " " & im & "' " & s & """"
You can get the unicode hex number (B0 in this case) for a symbol from the Insert Symbol dialog box. Take the number and prefix it with &H to put it in VB Hex form. then convert the number to a character with the Chr() function. Or, just that little degree symbol that you just inserted in your post above, copy it, and paste it into your VBA editor. Or just copy the following line: formDMS = d & "° " & im & "' " & s & """" I just tried it. It works too. :-) ---- Nick Hebb BreezeTree Software http://www.breezetree.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sure does Nick.... Thanks a heap.
---- Geoff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Converting Decimal Degrees to Degrees/Minutes/Seconds | Excel Worksheet Functions | |||
How do you convert decimal degrees to degrees minutes seconds | Excel Discussion (Misc queries) | |||
how can i convert degrees/minutes/seconds to decimal degrees? | Excel Discussion (Misc queries) | |||
calculate from degrees to degrees/minutes/seconds on excel? | Excel Worksheet Functions | |||
converting from digital degrees to degrees minutes seconds | Excel Worksheet Functions |