Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to convert decimal degrees to degrees minutes seconds in Excel?

Sometimes, you may have a list of data shown as decimal degrees in a worksheet, and now you need to convert the decimal degrees to degrees, minutes and seconds formatting as shown as following screenshots, how can you get the conversation quickly in Excel?

Convert decimal degrees to degrees, minutes, seconds with VBA

Convert degrees, minutes, seconds to decimal degrees with VBA

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial


arrow blue right bubble Convert decimal degrees to degrees, minutes, seconds with VBA


Please follow the steps below to convert decimal degrees to degrees, minutes, and seconds with VBA code.

1. Hold ALT button and press F11 on the keyboard to open a Microsoft Visual Basic for Application window.

2. Click Insert > Module, and copy the VBA into the module.

VBA: Convert decimal degree to degree, minutes and seconds

Sub ConvertDegree()
'Update 20130815
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    num1 = Rng.Value
    num2 = (num1 - Int(num1)) * 60
    num3 = Format((num2 - Int(num2)) * 60, "00")
    Rng.Value = Int(num1) & "°" & Int(num2) & "'" & Int(num3) & "''"
Next
End Sub

3. Click Run button or press F5 to run the VBA.

4. A dialog displayed on the screen, and you can select the cells you want to the convert. See screenshot:

5. Click OK, then the selected data is converted to degree, minutes and seconds. See screenshot:

Tip: Using the above VBA code will lost your original data, so you’d better copy the data before running the code.


arrow blue right bubble Convert degrees, minutes, seconds to decimal degrees with VBA

Sometimes, you may want to convert the data in degrees/minutes/seconds formatting to decimal degrees, the following VBA code can help you quickly get it done.

1. Hold ALT button and press F11 on the keyboard to open a Microsoft Visual Basic for Application window.

2. Click Insert > Module, and copy the VBA into the module.

VBA: Convert degree, minutes and seconds to decimal degree

Function ConvertDecimal(pInput As String) As Double
'Updateby20140227
Dim xDeg As Double
Dim xMin As Double
Dim xSec As Double
xDeg = Val(Left(pInput, InStr(1, pInput, "°") - 1))
xMin = Val(Mid(pInput, InStr(1, pInput, "°") + 2, _
             InStr(1, pInput, "'") - InStr(1, pInput, _
             "°") - 2)) / 60
xSec = Val(Mid(pInput, InStr(1, pInput, "'") + _
            2, Len(pInput) - InStr(1, pInput, "'") - 2)) _
            / 3600
ConvertDecimal = xDeg + xMin + xSec
End Function

3. Save the code and close the window, select a blank cell, for instance, the Cell A1, enter this formula =ConvertDecimal("10° 27' 36""") ("10° 27' 36""" stands the degree you want to convert to decimal degree, you can change it as you need), then click Enter button. See screenshots:


Relative articles

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    ValdrichF · 28 days ago
    The code has a assumes there is a space after ° and '. Change the 2's to 1's in the code to solve it.
    Function ConvertDecimal(pInput As String) As Double
    'Updateby20140227
    Dim xDeg As Double
    Dim xMin As Double
    Dim xSec As Double
    xDeg = Val(Left(pInput, InStr(1, pInput, "°") - 1))
    xMin = Val(Mid(pInput, InStr(1, pInput, "°") + 1, _
    InStr(1, pInput, "'") - InStr(1, pInput, _
    "°") - 1)) / 60
    xSec = Val(Mid(pInput, InStr(1, pInput, "'") + _
    1, Len(pInput) - InStr(1, pInput, "'") - 1)) _
    / 3600
    ConvertDecimal = xDeg + xMin + xSec
    End Function
  • To post as a guest, your comment is unpublished.
    Sandeep · 1 years ago
    Works like a champ! Thanks for sharing!!!
  • To post as a guest, your comment is unpublished.
    ahans · 1 years ago
    please
    i want you help and write a computer program on paper to convert decimal of degree to degree minute and second.
    317.5986740026
    from ahans.
    • To post as a guest, your comment is unpublished.
      Amjid afridi · 1 years ago
      step 1, Multiply numbers after decimal with 60 (0.5986740026*60)minutes=35.92044015 mean 35 mints
      spet 2, multiply the decimal after minute ie 0.9204401*60=55.2264
      so 317 degree 35 minuts 55 sec
  • To post as a guest, your comment is unpublished.
    Corny · 1 years ago
    Not sure whats wrong with the code in the post from Ernie, but this is what I use to convert decimal degrees to DMS degrees in the spread sheet without using VB. The reference to the cell E33 is the cell containing the decimal degrees value.

    =CONCAT(FIXED(INT(B32), 0) , "°", FIXED(((B32 - INT(B32)) * 60), 0), "'", FIXED(((B32 - INT(B32) - INT(B32 - INT(B32))) * 3600), 0 ,TRUE), """)

    Good luck.
    • To post as a guest, your comment is unpublished.
      RAMON GOMEZ · 1 years ago
      HI CORNY, NOT WORK FOR ME, EXCEL DO NOT ACCEPT THE FUNCTION..... WHATS WRONG? CAN YOU HELP ME?
  • To post as a guest, your comment is unpublished.
    Ernie · 2 years ago
    Hello,
    I used the scrip to convert decimal to DMS however the code is wrong somewhere as it turned out 37.856908,-120.912469 to 37D 51M 25S, -121D 5M 15S
    This is way off....

    Anyone have a fix for this?