As Chip (
http://www.cpearson.com/Excel/latlong.aspx )
points out lat/long can be represented using either time format or a custom
format
I will show how to get 39º07'57"
I will let you look at his site to see how to reformat to get 39º07'57"
With 390757 in A1 use these formulas
in B1: =INT(A1/10000) to get 39
in C1 use =MOD(INT(A1/100),100) to get 7 (do not worry about leading zero)
in D1 use =MOD(A1,100) to get 57
Now it is tempting to use =TIME(B1,C1,D1) but TIME always makes the hours
less than 24 so we would get 15:07:57
Rather use =(B1/24)+(C1/(24*60))+(D1/(24*60*60)) and format the cell with
[hh]:mm:ss
I know the formula could be simplified but I wanted to show how it works:
since Excel stores time as a fraction of a day we must make all three values
fractions of a day
When you have it working you can do in one formula
=(INT(A1/10000)/24)+(MOD(INT(A1/100),100)/(24*60))+(MOD(A1,100)/(24*60*60))
Bad lightening storm, must sign off
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email
"Cheese" wrote in message
...
I have an Excel spreadsheet with Lat/Lon coordinates in an unusual format.
The Degrees, Minutes, Seconds are merged together as text, without spaces.
They're in two columns, like this:
Lat, Lon
390757, 0902243
These numbers are the equivalent of 39° 07' 57", 90° 22' 43". I want to
convert these columns to their decimal equivalents, like this: 39.1325°,
90.378611°.
I have Excel 2002.
Unfortunately, I'm clueless with Visual Basic. Macros I can handle.
Thanks!