LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Simple way to convert UTM ED50 coordinates to decimal coordinates?

Here is an attempt using Regular Expressions if you want to try that. I'm
not familiar with ED50. For your return example of Longitude 8.415077778,
do you want to place a "-" in front of it to indicate "East" Longitude? I
left the N & E as is. I used 1 multiplication and 1 Division, instead of 2
divisions. If you are doing many of these, you would want to pull out the
RegExp as a global object so that you do not keep creating the object with
each call.
(As a side note, I could not find any information on converting the data to
WGS 84 if that is what you wanted also.)
Again, just an idea I was playing with. There are many other ways to do
this. RegExp tend to be a little slow, but there are no programming loops
either.

Debug.Print ED50_Clean(Range("A1"))

N 46.572525 E 8.41507777777778

Function ED50_Clean(s As String) As String
'// = = = = = = = = = = = = = = = = = = = = = = = = =
'// Requires VBA Library Reference:
'// Microsoft VBScript Regular Expressions 5.5
'// = = = = = = = = = = = = = = = = = = = = = = = = =

Dim v As Variant
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "([0-9.]|[NESW])+"
Set v = .Execute(s)
' d + (60*m + s)/3600
If v.Count = 8 Then
ED50_Clean = _
v(3) & Space(1) & v(0) + (60 * v(1) + v(2)) / 3600 & Space(1) &
v(7) & Space(1) & v(4) + (60 * v(5) + v(6)) / 3600
Else
ED50_Clean = "Error in String"
End If
End With
End Function


HTH
Dana DeLouis


"Dan" wrote in message
...
Hi there,

I do have a string in a cell that looks like this (this is UTM ED50

format):

46° 34' 21.09" N 8° 24' 54.28" E


I need to convert this string to Latitude and Longitude. The calculation
method is pretty simple. In the example above, its
46 + 34/60 + 21.09/3600 = 46.572525 (Lattitude)
8 + 24/60 + 54.28/3600 = 8.415077778 (Longitude)

So, the calculation as such is not very complicated.
What drives me nuts is to get the numbers out of the long ED50 string. I
managed this with a LOT of SEARCH() and MID() functions, but it's just
awfull !!.

Latitude

=MID($K2,1,SEARCH("°",$K2)-1)+(MID($K2,SEARCH("°",$K2)+1,(SEARCH("'",$K2)-SE

ARCH("°",$K2))-1))/60+(MID($K2,SEARCH("'",$K2)+1,(SEARCH("""",$K2)-SEARCH("'
",$K2))-1)/3600)
Longitude

=MID(MID($K2,22,15),1,SEARCH("°",MID($K2,22,15),1)-1)+MID(MID($K2,22,15),SEA

RCH("°",MID($K2,22,15),1)+1,SEARCH("'",MID($K2,22, 15),1)-SEARCH("°",MID($K2,

22,15),1)-1)/60+MID(MID($K2,22,15),SEARCH("'",MID($K2,22,15),1) +1,SEARCH("""
",MID($K2,22,15),1)-SEARCH("'",MID($K2,22,15),1)-1)/3600

Anyone knows a simpler way?

Thanks

Dan



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coordinates 5F80YZ Excel Worksheet Functions 3 September 9th 09 12:47 AM
Converting Lat/Lon coordinates to Decimal Cheese Excel Discussion (Misc queries) 4 June 25th 09 11:12 PM
How do I convert Easting/ Northing GPS coordinates into Lat/Long? Stacey Excel Discussion (Misc queries) 1 June 12th 07 03:58 AM
convert x/y coordinates to a shape file to use in Cad? LLM Excel Discussion (Misc queries) 1 February 9th 07 01:40 AM
Converting MouseDown Coordinates to Chart Point Coordinates Steve[_50_] Excel Programming 3 December 2nd 03 06:48 PM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"