View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default Separating words in a single cell

On Thu, 15 Jun 2006 19:22:29 +0200, "Ardus Petus"
wrote:

Create an UDF (User Defined Function) in a module with following code:

'----------------------------------------------------
Function FirstLast(sText As String) As String
Dim re As RegExp
If re Is Nothing Then
Set re = New RegExp
re.Pattern = "([A-Z][a-z]*)([A-Z][a-z]*)"
re.IgnoreCase = False
re.Global = True
End If

FirstLast = re.Replace(sText, "$1 $2")
End Function
'---------------------------------------------------------------------


Slight modification to put a <space before every capital except the first:

===========================================
Function FirstLast(sText As String) As String
Dim re As RegExp
If re Is Nothing Then
Set re = New RegExp
re.Pattern = "([A-Z])"
re.IgnoreCase = False
re.Global = True
End If

FirstLast = Trim(re.Replace(sText, " $1"))
End Function
==============================================
--ron