【问题标题】:excel formula calculationexcel公式计算
【发布时间】:2013-09-11 19:36:22
【问题描述】:

我的 Excel 表格中有大约 200 个纬度和 200 个经度的不同地方,格式为-

度、分和秒 - 例如:36°34"44'

此值存储在单个单元格中。

我想使用公式度+分/60+秒/3600 将此值转换为小数。请告诉我如何在每个单元格中应用相同的内容。问题是所有度数、分钟数和秒数都在同一个单元格中。提前致谢!

【问题讨论】:

    标签: excel latitude-longitude


    【解决方案1】:

    这是您可能可以使用的示例 VBA 函数:

    Function Convert_Decimal(Degree_Deg As String) As Double
       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
    

    要使用,只需输入=Convert_Decimal("36°34"44'"),您将得到结果 36.58。

    另外,如果您有兴趣,可以查看利用时间格式功能的the other approach

    希望这些会有所帮助。

    MSDN 上的一些详细信息:

    http://support.microsoft.com/kb/73023

    http://support.microsoft.com/kb/213449

    http://www.cpearson.com/excel/LatLong.aspx

    【讨论】:

      【解决方案2】:

      如果您的字符串填充为零(如06°04"04'),则使用

      =VALUE(LEFT(A1,2))+VALUE(MID(A1,4,2))/60+VALUE(MID(A1,7,2))/3600
      

      如果不是,或者不确定(如6°4"4'),则使用

      =VALUE(LEFT(A1,FIND("°",A1)-1)) + 
       VALUE(MID(A1,FIND("°",A1)+1,FIND("""",A1)-FIND("°",A1)-1))/60 + 
       VALUE(MID(A1,FIND("""",A1)+1,FIND("'",A1)-FIND("""",A1)-1))/3600
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-11
        相关资源
        最近更新 更多