Help with parsing string and remove leading and trailing spaces and tabs and line breaks

tbruce

Board Regular
Joined
Dec 9, 2013
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Trying to parse the following data in cell A1 and remove leading and trailing spaces, line breaks and tabs that seem to be present in the raw data of the cell. The following formula works to parse the needed data, but the spaces, tab and line breaks are causing me problems after I convert B2 to values (V)123. I just need to parse the latitude and longitude - don't need the Altitude.
Any help would be appreciated.

=(MID(LEFT(A2,FIND("Altitude",A2)-1),FIND("Latitude",A2)+9,LEN(A2)))

BodyLatitudeLongitude
Latitude 037 46 45.304N
Longitude 122 25 49.541W
Altitude 182 meter (above sea level)
037 46 45.304N
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Is this what you are after?

22 03 06.xlsm
ABC
1BodyLatitudeLongitude
2Latitude 037 46 45.304N Longitude 122 25 49.541W Altitude 182 meter (above sea level)037 46 45.304N122 25 49.541W
Lat Long
Cell Formulas
RangeFormula
B2B2=MID(LEFT(A2,FIND(CHAR(10),A2)-1),10,20)
C2C2=REPLACE(LEFT(A2,FIND("Altitude",A2)-2),1,FIND("Longitude",A2)+9,"")
 
Upvote 0
Hi,

Another way, B2 formula copied to C2:

Book3.xlsx
ABC
1BodyLatitudeLongitude
2Latitude 037 46 45.304N Longitude 122 25 49.541W Altitude 182 meter (above sea level)037 46 45.304N122 25 49.541W
Sheet1033
Cell Formulas
RangeFormula
B2:C2B2=MID($A2,FIND(B1,$A2)+LEN(B1)+1,14)
 
Upvote 0
Hi again, so now I'm thinking, since I really don't know much about Latitude and Longitude formats, how many different ways it may show in OP's data.
My formula above relies on a fixed length of 14 characters, which I'm thinking may Not be in all cases, so may be these may work, just in case:

Book3.xlsx
ABC
1BodyLatitudeLongitude
2Latitude 037 46 45.304N Longitude 122 25 49.541W Altitude 182 meter (above sea level)037 46 45.304N122 25 49.541W
Sheet1033
Cell Formulas
RangeFormula
B2B2=MID(A2,10,FIND(CHAR(10),A2)-10)
C2C2=MID(LEFT(A2,FIND("Altitude",A2)-2),FIND(C1,A2)+10,99)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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