Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Separate Concatenated First/Last Name

I have a spreadsheet with a column of cells containing concatenated first and
last names. The Last Name is denoted by a capital first letter.

For Example: BillGates

How might I separate the first and last name into separate cells?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Separate Concatenated First/Last Name

Sub Separate()
Dim iloc As Long, i As Long
Dim cell As Range, sStr As String
For Each cell In Selection
sStr = cell.Value
i = Len(sStr) + 1
For iloc = Len(sStr) To 1 Step -1
If UCase(Mid(sStr, iloc, 1)) = Mid(sStr, iloc, 1) Then
i = iloc
Exit For
End If
Next
If i < Len(sStr) + 1 Then
cell.Value = Left(sStr, i - 1)
cell.Offset(0, 1).Value = Right(sStr, Len(sStr) - i + 1)
End If
Next
End Sub

--
Regards,
Tom Ogilvy



"Al" wrote in message
...
I have a spreadsheet with a column of cells containing concatenated first

and
last names. The Last Name is denoted by a capital first letter.

For Example: BillGates

How might I separate the first and last name into separate cells?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Separate Concatenated First/Last Name

Wow Tom!! Thanks a BUNCH!!

"Tom Ogilvy" wrote:

Sub Separate()
Dim iloc As Long, i As Long
Dim cell As Range, sStr As String
For Each cell In Selection
sStr = cell.Value
i = Len(sStr) + 1
For iloc = Len(sStr) To 1 Step -1
If UCase(Mid(sStr, iloc, 1)) = Mid(sStr, iloc, 1) Then
i = iloc
Exit For
End If
Next
If i < Len(sStr) + 1 Then
cell.Value = Left(sStr, i - 1)
cell.Offset(0, 1).Value = Right(sStr, Len(sStr) - i + 1)
End If
Next
End Sub

--
Regards,
Tom Ogilvy



"Al" wrote in message
...
I have a spreadsheet with a column of cells containing concatenated first

and
last names. The Last Name is denoted by a capital first letter.

For Example: BillGates

How might I separate the first and last name into separate cells?

Thanks in advance.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
separate two dates from a text string into two separate cells Tacrier Excel Discussion (Misc queries) 3 October 13th 08 08:53 PM
Open Separate Excel Files in Separate Windows JTWood Excel Discussion (Misc queries) 3 May 7th 06 10:18 PM
Splitting a concatenated string into separate rows... Natarajan Excel Worksheet Functions 1 May 4th 06 05:57 PM
Open Excel files in separate sessions, not just separate windows? Bob at Dexia Design Excel Discussion (Misc queries) 1 October 18th 05 05:46 PM
Separate Concatenated First,Last Names Al Excel Programming 1 October 20th 04 06:15 PM


All times are GMT +1. The time now is 06:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"