0% found this document useful (0 votes)
27 views

Convert Dms Deg

This document provides instructions and sample code for converting between angular measurements expressed in degrees/minutes/seconds (DMS) and decimal degrees in Microsoft Excel 2000. It includes a custom function to convert a decimal degree value to a DMS text string, and another to convert a DMS text string to a decimal degree value. Both functions are provided as examples for users to copy and paste into a VBA module in Excel.

Uploaded by

Preggy Pillay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Convert Dms Deg

This document provides instructions and sample code for converting between angular measurements expressed in degrees/minutes/seconds (DMS) and decimal degrees in Microsoft Excel 2000. It includes a custom function to convert a decimal degree value to a DMS text string, and another to convert a DMS text string to a decimal degree value. Both functions are provided as examples for users to copy and paste into a VBA module in Excel.

Uploaded by

Preggy Pillay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

How to convert degrees/minutes/seconds angles to or from decimal angles in Excel 20...

Page 1 of 2

Find it myself Select the product for which you want to find a solution

Ask the community

Windows Internet Office Xbox Media Player Skype Windows More Products
Get live help Explorer Phone

How to convert degrees/minutes/seconds angles to or from decimal angles


in Excel 2000
Article ID: 213449 - View products that this article applies to.

This article was previously published under Q213449

For a Microsoft Excel 97 version of this article, see 121944 (http://support.microsoft.com/kb/121944/ ) .

For a Microsoft Excel 98 version of this article, see 192367 (http://support.microsoft.com/kb/192367/ ) .

SUMMARY

Angular measurements are commonly expressed in units of degrees, minutes, and seconds (DMS). One degree equals 60 minutes, and one minute equals 60
seconds. To simplify some mathematical calculations you may want to express angular measurements in degrees and decimal fractions of degrees.

This article contains a sample custom function you can use to convert a degree value stored in decimal format, to DMS stored in text format, and a sample
function that converts DMS to a degree value stored in decimal format.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties
of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify
these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit
these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104)

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice)

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web
site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)

Converting Decimal Degrees to Degrees/Minutes/Seconds


The following Microsoft Visual Basic for Applications custom function accepts an angle formatted as a decimal value and converts it to a text value displayed in
degrees, minutes, and seconds.

Function Convert_Degree(Decimal_Deg) As Variant With Application 'Set degree to Integer of Argument Passed Degrees = Int
(Decimal_Deg) 'Set minutes to 60 times the number to the right 'of the decimal for the variable Decimal_Deg Minutes =
(Decimal_Deg ­ Degrees) * 60 'Set seconds to 60 times the number to the right of the 'decimal for the variable Minute Seconds =
Format(((Minutes ­ Int(Minutes)) * 60), "0") 'Returns the Result of degree conversion '(for example, 10.46 = 10~ 27 ' 36")
Convert_Degree = " " & Degrees & "° " & Int(Minutes) & "' " _ & Seconds + Chr(34) End With End Function

To use this function, create a conversion formula, as in the following example:

1. Start Excel and press ALT+F11 to start the Visual Basic editor.
2. On the Insert menu, click Module.
3. Enter the sample code for the Convert_Degree custom function described above into the module sheet.
4. Press ALT+F11 to return to excel.
5. In cell A1 type 10.46.
6. In cell A2 type the following formula:
=Convert_Degree(A1)

The formula returns 10°27'36"

Converting Degrees/Minutes/Seconds to Decimal Degrees


The following Microsoft Visual Basic for Applications custom function accepts a text string of degrees, minutes and seconds formatted in the exact same format
that the Convert_Degree function returns (for example, 10° 27' 36") and converts it to an angle formatted as a decimal value. This is exactly the reverse of the
Convert_Degree custom function.

WARNING: This custom function fails if the Degree_Deg argument is not in the following format

http://support.microsoft.com/?kbid=213449 14/06/2013
How to convert degrees/minutes/seconds angles to or from decimal angles in Excel 20... Page 2 of 2

< degrees>° <minutes>' <seconds>"

even if the seconds value is 0.


Function Convert_Decimal(Degree_Deg As String) As Double ' Declare the variables to be double precision floating­point. Dim
degrees As Double Dim minutes As Double Dim seconds As Double ' Set degree to value before "°" of Argument Passed. degrees =
Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") ­ 1)) ' Set minutes to the value between the "°" and the "'" ' of the text
string for the variable Degree_Deg divided by ' 60. The Val function converts the text string to a number. minutes = Val(Mid
(Degree_Deg, InStr(1, Degree_Deg, "°") + 2, _ InStr(1, Degree_Deg, "'") ­ InStr(1, Degree_Deg, _ "°") ­ 2)) / 60 ' Set seconds
to the number to the right of "'" that is ' converted to a value and then divided by 3600. seconds = Val(Mid(Degree_Deg, InStr
(1, Degree_Deg, "'") + _ 2, Len(Degree_Deg) ­ InStr(1, Degree_Deg, "'") ­ 2)) _ / 3600 Convert_Decimal = degrees + minutes +
seconds End Function

To use this function, create a conversion formula, as in the following example:

1. Start Excel and press ALT+F11 to start the Visual Basic Editor.
2. On the Insert menu, click Module.
3. Enter the sample code for the Convert_Decimal custom function described above into the module sheet.
4. Press ALT+F11 to return to excel.
5. In cell A1 type the following formula:
=Convert_Decimal("10° 27' 36""")

NOTE: You are required to type three quotation marks (""") at the end of the argument of this formula to balance the quotation mark for the seconds and
the quotation mark for the text string. A cell reference will not require a quotation mark.
6. The formula returns 10.46

Properties

Article ID: 213449 - Last Review: November 23, 2006 - Revision: 4.6
APPLIES TO
• Microsoft Excel 2000 Standard Edition

Keywords: kbfunctions kbconvert kbsample kbdtacode kbhowto kbprogramming KB213449

Give Feedback
Back to the top

http://support.microsoft.com/?kbid=213449 14/06/2013

You might also like