View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
doc doc is offline
external usenet poster
 
Posts: 12
Default Decimal numbers in Excel

Thanks Mike,
I tried but never could get it to work. I kept getting a "compile error".
Probably something I did wrong, I know ABSOUUTELY NOTHING about writing OR
running VB modules.
I did, in the mean time figure out how to do it with the integer function.
Thanks.
Doc




"Mike H" wrote:

Hi,

Try this to convert decimal degrees to deg, mins & seconds

Alt +F11 to open VB editor, right click 'ThisWorkbook' and insert module and
paste this UDF in

call with

=ConvDeg(a1)

Function ConvDeg(DecAngle) As Variant
Degs = Int(DecAngle)
Mins = (DecAngle - Degs) * 60
secs = Format(((Mins - Int(Mins)) * 60), "0")
ConvDeg = " " & Degs & "° " & Int(Mins) & "' " & secs & """"
End Function

Mike

"Doc" wrote:

Is there a way to separate and use the numbers, to the left of and to the
right of the decimal point in a single cell?
I am trying to convert angles given in decimal form (i.e. 27.286°), to the
older form of degrees, minutes and seconds (i.e. 27°1710), then store the
degrees in one cell, the minutes in another cell, and the seconds in a third.
I can make it work the OTHER way with multiplication and addition, because
that doesnt require the SEPARATION of a number.