我已經GOOGLE了很多,但沒有找到任何解決方案。我想在Excel中將Lat Long數據(度,分,秒)轉換爲十進制數。如何在Excel中將度數/分鐘轉換爲小數?
傳統Lat Long網數據就像25°43'21.3"
,但我的工作沒有度(°)符號的數據庫,它具有點(。),而不是degree.For例 - 25.43'21.3"
那麼會有什麼將25.43'21.3"
轉換成十進制的腳本,如25.722583333333333
??
當數據帶有(°)符號時,以下代碼有效。
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
只需更換' 「°」 用''' –
怎麼會更換工作。 「」?數據包含幾個點(。) – netmaster
'InStr'將返回第一個'。'的位置,它找到 –