Add space in cell when in one word something starting with Capital

jellevansoelen

New Member
Joined
Mar 1, 2021
Messages
29
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi,

I have a large Excel file with a lot of this cells:
Book2
A
1Build house / buildingDowntown 12, Amsterdam
2Move barn by usThe Wolfstreet 14, Rotterdam
3Set commercialSquare 12, Den Haag
Sheet1


There was a conversion error, which put the street directly after the last word.
Now i'm looking for a solution which put a space for this street.
I'm looking for a script which put a space when in the middle of a word is being a capital.

You can see it in the example by the red bold letters:
Book2
A
1Build house / buildingDowntown 12, Amsterdam
2Move barn by usThe Wolfstreet 14, Rotterdam
3Set commercialSquare 12, Den Haag
Sheet1


I want that the cells looking on this way:
Book2
A
1Build house / building Downtown 12, Amsterdam
2Move barn by us The Wolfstreet 14, Rotterdam
3Set commercial Square 12, Den Haag
Sheet1


Is there some possibility to do that?

Tnx,
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Sorry, this is the second image:
You can see it in the example by the red bold letters:

Build house / buildingDowntown 12, Amsterdam
Move barn by usThe Wolfstreet 14, Rotterdam
Set commercialSquare 12, Den Haag
 
Upvote 0
Upvote 0
This vba code will change the selected cells (must be cells in one column only selected) by adding a comma and a space before the first capital letter occurring on or after position 2. Try it on a copy of your spreadsheet.

VBA Code:
Sub AddSpaces()
    If Selection.Columns.Count > 1 Then Exit Sub
    Dim a As Variant, j As Long, s As Variant, i As Long, found As Boolean, cd As Integer, ls As Integer
    a = Selection.Value
    For Each s In a
        j = j + 1
        found = False
        i = 2
        ls = Len(s)
        Do While Not found And i <= ls
            cd = Asc(Mid(s, i, 1))
            If cd >= Asc("A") And cd <= Asc("Z") Then
                a(j, 1) = Mid(s, 1, i - 1) & ", " & Mid(s, i)
                found = True
            Else
                i = i + 1
            End If
        Loop
    Next
    Selection = a
End Sub
 
Upvote 0
If you want a comma & space, just add the comma to my formula in Post #3 like below, otherwise, if you only want the space, as you stated in OP, use formula in Post #3 as-is.

Book3.xlsx
AB
1Build house / buildingDowntown 12, AmsterdamBuild house / building, Downtown 12, Amsterdam
2Move barn by usThe Wolfstreet 14, RotterdamMove barn by us, The Wolfstreet 14, Rotterdam
3Set commercialSquare 12, Den HaagSet commercial, Square 12, Den Haag
Sheet865
Cell Formulas
RangeFormula
B1:B3B1=REPLACE(A1,MIN(FIND(CHAR(ROW($65:$90)),A1&CHAR(ROW($65:$90)),2)),,", ")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,835
Messages
6,121,880
Members
449,057
Latest member
Moo4247

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