Split Uppercase words in Excel

Visual Basic .Net picture Visual Basic .Net · Apr 17, 2012 · Viewed 21.4k times · Source

I would like to split all words in my cell by Uppercase, an example:

Original values:

MikeJones
RinaJonesJunior
MichealSamuelsLurth

Expected output:

Mike Jones
Rina Jones Junior
Micheal Samuels Lurth

Can this be done without using VBA?

Answer

brettdj picture brettdj · Apr 18, 2012

Having acknowledged Excellll's remarkable formula, the most efficient code solution would be RegExp based. This avoids long loops.

enter image description here

Function SplitCaps(strIn As String) As String
Dim objRegex As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
    .Global = True
    .Pattern = "([a-z])([A-Z])"
    SplitCaps = .Replace(strIn, "$1 $2")
End With
End Function