Need formula to put a space in postcode cell

BoldB

New Member
Joined
Apr 20, 2013
Messages
16
Hi,

Is there a formula that can look to see if there is a space in the data in a cell and if there is not, insert a space 3 digits from the end.

So the postcodes TA1 2BN and LS12 8PO would be left as they are and TA12BN and LS128PO would become TA1 2BN and LS12 8PO?

So the table would end up like this:

Data Formula
TA1 2BNTA1 2BN
LS12 8POLS12 8PO
TA12BNTA1 2BN
LS128POLS12 8PO

<tbody>
</tbody>


Kind Regards
Steven

<tbody>
</tbody>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

BobUmlas

Well-known Member
Joined
Mar 14, 2002
Messages
1,181
=if(mid(a1,len(a1)-4,1)=" ",a1,left(a1,len(a1)-3)&" "&right(a1,3))
 

raj2206

Board Regular
Joined
Jul 23, 2012
Messages
213
Hey,
Thanks for writing!

You can use the following formula:
=IF(IFERROR(FIND(" ",A2)>0,0),A2,REPLACE(A2,LEN(A2)-2,0," "))

Change the referencing as per the requirement.

Hope this will help,

Raj
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,090
Messages
5,835,337
Members
430,351
Latest member
ddalton

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
Top