Text Manipulation

purceld2

Well-known Member
Joined
Aug 18, 2005
Messages
586
Office Version
  1. 2013
Platform
  1. Windows
I am trying to strip of the postcode /zip code and put in a cell on its own can someone advise the bust why to do this data below.

Excel Workbook
A
5Aberdeen AB11 8HX
6Acocks Green B27 7UW
7Acton W3 8HH
8Aldershot GU11 1JG
9Altrincham WA14 5PZ
10Ashford TN24 0SP
11Aylesbury HP20 1JH
12Banbury OX16 2RL
13Bangor LL57 4SU
14Basildon SS14 3GD
15Basingstoke RG21 8BJ
16Bath BA1 3AG
17Beckenham BR3 4TJ
18Bedford (Midland) MK40 1QH
19Bedford (St John's) MK42 0XE
20Bedminster BS3 3PZ
21Belshill ML4 1BA
22Birmingham (Perry Barr) B44 8AA
23Blackburn BB2 3DY
24Bolton BL2 1HE
25Bournemouth BH8 8BD
26Bradford BD5 7JL
27Braintree CM77 8YH
28Bridgwater TA6 4DB
29Brighton BN1 4GD
30Bristol (Downend) BS15 1SE
31Bristol (Filton) BS34 7JU
32Bristol (Newfoundland) BS2 9AP
33Burntwood (UK Autocare) WS7 3TQ
34Burton DE14 1SN
35Bury St Edmunds IP33 1XP
36Camberley GU15 3EJ
37Camborne TR15 3PS
38Cambridge (Clifton) CB1 7EA
summary


thank you in advance
 
Thanks all but for lesser mortals like me could someone explain how Bosco's formula works please.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Thanks all but for lesser mortals like me could someone explain how Bosco's formula works please.

TRIM(RIGHT(SUBSTITUTE( ," ",REPT()))) is a method to obtain the last word in a string.

For example: TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",255)),255)) will replace all spaces in A1 with 255 spaces and return a string of 255 characters from the right. TRIM removes all excessive spaces and you are left with the last word.

Manipulating the numbers will allow you to get the last word, last two words etc.

In this case: TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",50)),100))

This replaces all spaces with 50 spaces and returns 100 characters from the right. This is guaranteed to return the last 2 words with a whole load of spaces as long as each word is less than 25 characters (which is the case most of the time. If not, you can just increase the numbers. Note that the numbers within REPT and RIGHT have to multiples for this to work properly).

Example: In the tables given here the last two words in A1 is AB11 8HX. This function returns 8HX (3 characters) + 50 spaces + AB11 (4 characters) + 47 spaces (total 100 characters). TRIM then trims out excessive spaces and you are left with AB11 8HX.

Hope this helps.
 
Last edited:
Upvote 0
Sandeep thanks you very much for taking the time to explain the formula, very much appreciated
 
Upvote 0
This works brilliantly for copying the data and I thank you all.
However, is it possible to cut and paste it?
I have over 2000 customers whos addresses are on a single line and so far its taken me two mind numbing hours to do just over 100!!!! :LOL:
 
Upvote 0
Hi & welcome to the Board!

What do you mean when you say

....
is it possible to cut and paste it?
I have over 2000 customers whos addresses are on a single line and so far its taken me two mind numbing hours to do just over 100!!!! ..

What is it you are trying to achieve?
 
Upvote 0
Hi Sandeep.

Basically I have a very old database that I've converted to a CSV file. Unfortunately each of the fields contain too much information for me to use in a database. So I'm trying to fix it before importing it into a proper database.

So, the existing 'Name' field might contain a complete name, for example, 'Smith, Fred Mr'. What I need to do is somehow transfer (NOT copy) Smith into the LastName field, Fred into the FirstName field and Mr into a Salutation field.

I hope that makes sense.
 
Last edited:
Upvote 0
Ok.

Is "Smith, Fred Mr" the only format or are there others? (i.e. In this case - the name starts with the last name, followed by a comma. The salutation is always the last word in the sentence. Everything between the comma and the salutation go in the first name column.)
 
Upvote 0
Unfortunately no! What I'd like to understand Sandeep is how to construct a formula to 'pick out' certain elements of a cell's contents. Is that possible?:wink:
 
Upvote 0
It certainly is possible. As long as you know what text you want extracted. There needs to be some identifiers eg. it occurs before/after some text/number/punctuation, or is x characters long, or is present in a list somewhere else etc.

Unless you define parameters this is not possible.
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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