View Single Post
  #3  
Old September 26th, 2009, 12:04 PM posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.newusers
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
Default Map co-ordinates conversion

On Sat, 26 Sep 2009 09:28:29 +0100, "Bill R"
wrote:

The following converts latitude co-ordinates in cell A3 from NN:NN:NN and
N:NN:NN format to N.NN format. (A similar formulae does the same for
longitude co-ordinates.)

=IF(RIGHT(A3,1)="W",IF(MID(A3,2,1)=":",(LEFT(A3,1 ))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60))*-1,IF(MID(A3,2,1)=":",(LEFT(A3,1))+(MID(A3,3,2)/60)+(MID(A3,6,2)/60/60),(LEFT(A3,2))+(MID(A3,4,2)/60)+(MID(A3,7,2)/60/60)))

It is complicated as it needs to accommodate source information in degrees
in NN and N format (others are given in NN format) and, of course, the
output to be both positive (east of Greenwich and north of the equator) and
negative. Is there a better (shorter) formulae that will do the same job?

Thanks.

Bill R


To convert coordinates in "degrees" to decimal, merely multiply by 24 and
format the results as Number (or General) with the required number of decimal
places.

So, with the proper format for the cell:

=IF(ISERR(FIND(":",A1)),A1,IF(RIGHT(A1)="S",-1,1)*LEFT(A1,LEN(A1)-1)*24)

This formula has no error checking for blank cells or improperly formatted
entries (e.g. no N or S at the end). That could certainly be easily added.

--ron