Inserting a space between text in cells belonging to one column

pialajoie

New Member
Joined
Jun 5, 2014
Messages
1
I am operating Excel for Mac 2011 version 14.4.2

I have a list of 1500 addresses in a column, something like, 5VistaTerrace, and I need to insert a space between the number and each of the words so that it reads 5 Vista Terrace in the cell.

All of the addresses are different, some with 4 or 5 words like 5ABrownBayCourt... that particular one I would want to read 5A Brown Bay Court in the end.

Is there a formula or excel trick I can perform to save me the time of manually adding the spaces?

Much obliged.:rolleyes::rolleyes::rolleyes:
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Give this UDF (user defined function) a try...
Code:
Function Spaces(TextIn As String) As String
  Dim X As Long
  Spaces = TextIn
  For X = Len(Spaces) To 2 Step -1
    If Mid(Spaces, X - 1, 2) Like "[a-z][A-Z0-9]" Or Mid(Spaces, X - 1, 2) Like "[a-z][A-Z]" Then
      Spaces = Application.Replace(Spaces, X, 0, " ")
    End If
  Next
  For X = 1 To InStr(Spaces & " ", " ") - 1
    If Mid(Spaces, X, 3) Like "[A-Z][A-Z][a-z]" Or Mid(Spaces, X, 3) Like "#[A-Z][a-z]" Then
      Spaces = Application.Replace(Spaces, X + 1, 0, " ")
    End If
  Next
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use Spaces just like it was a built-in Excel function. For example,

=Spaces(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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