Changing DMS into decimal degrees

kplunkett

New Member
Joined
Dec 28, 2023
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
Hello! I have a column of GPS coordinates in DMS style (like this: 31°59'42.5"N 87°17'37.0"W) but for some reason they won't upload to ArcGIS, so I was told to try changing them into decimal degrees (like this:
30.9951389, -87.29361). Is there a way to have Excel do the change automatically? I have over 3k entries and am dreading doing it by hand. Thank you all!!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I believe the formula is Degree+Minute/60+Second/3600 so 31°59'42.5"N becomes 31.99513889
Thus you could simply use text to columns and create a helper column that uses the formula on the split data. Probably faster than coding anything.
 
Upvote 0
Please try the following on a copy of your data. Put the following code in a standard module:
VBA Code:
Function DMS2DEC(s As String) As String
    Dim Sth As Boolean, Wst As Boolean, tmp
    Dim Lat As Double, Lon As Double
    If s Like "*S*" Then Sth = True
    If s Like "*W*" Then Wst = True
    Change = Array("°", """", "'")
    For Each a In Change
        s = Replace(s, a, " ")
    Next a
    tmp = Split(s, " ")
    
    If Sth = False Then
        Lat = CDbl(tmp(0)) + CDbl(tmp(1)) / 60 + CDbl(tmp(2)) / 3600
    Else
        Lat = -CDbl(tmp(0)) - CDbl(tmp(1)) / 60 - CDbl(tmp(2)) / 3600
    End If
    
    If Wst = False Then
        Lon = CDbl(tmp(4)) + CDbl(tmp(5)) / 60 + CDbl(tmp(6)) / 3600
    Else
        Lon = -CDbl(tmp(4)) - CDbl(tmp(5)) / 60 - CDbl(tmp(6)) / 3600
    End If
    DMS2DEC = Format(Lat, "#.00000000") & ", " & Format(Lon, "#.00000000")
End Function

Use it on your sheet like this (copy down to as many rows a you need).
Book1
AB
131°59'42.5"N 87°17'37.0"W31.99513889, -87.29361111
231°59'42.5"S 87°17'37.0"W-31.99513889, -87.29361111
331°59'42.5"N 87°17'37.0"E31.99513889, 87.29361111
431°59'42.5"S 87°17'37.0"E-31.99513889, 87.29361111
Sheet2
Cell Formulas
RangeFormula
B1:B4B1=DMS2DEC(A1)
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,231
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top