Convert and extract lat longs into separate fields

loto

New Member
Joined
Dec 17, 2011
Messages
11
Hi there,
I've extracted some lats and longs from Google and want to split them into separate cells and remove the degrees character and direction. Any idea how to do this in one go? e.g. I'd like to convert a whole load of lat/longs in one text string in a cell from this format to this:[TABLE="width: 267"]
<colgroup><col></colgroup><tbody>[TR]
[TD]e.g lat long cardiff[/TD]
[/TR]
[TR]
[TD]From:[/TD]
[/TR]
[TR]
[TD]51.4780° N, 3.1771° W[/TD]
[/TR]
[TR]
[TD]To:[/TD]
[/TR]
[TR]
[TD]51.4780,-3.1771[/TD]
[/TR]
[TR]
[TD]e.g. [/TD]
[/TR]
[TR]
[TD]lat long cape town[/TD]
[/TR]
[TR]
[TD]From:[/TD]
[/TR]
[TR]
[TD]33.9767° S, 18.4244° E[/TD]
[/TR]
[TR]
[TD]To:[/TD]
[/TR]
[TR]
[TD]-33.9767, 18.444[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 267"]
<tbody>[TR]
[TD="class: xl63, width: 267"]

[/TD]
[/TR]
</tbody>[/TABLE]
Any help as always would be much appreciated,
Thanks
Loto
 
With data in A1, in B1 enter:
=LEFT(A1,FIND(",",A1)-4)*IF(LEN(SUBSTITUTE(A1,"S",""))=LEN(A1),1,-1)
and in C1 enter:
=MID(A1,FIND(", ",A1)+2,FIND(", ",A1)-5)*IF(LEN(SUBSTITUTE(A1,"W",""))=LEN(A1),1,-1)

Thus if A1 contains: [TABLE="width: 140"]
<tbody>[TR]
[TD="width: 140"]51.4780° N, 3.1771° W

B1 will display [TABLE="width: 75"]
<tbody>[TR]
[TD="width: 75, align: right"]51.478
and C1 will display [TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64, align: right"]-3.1771[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top