If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > How to Split middle initial from the last name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-18-06, 09:37
arandomfrog arandomfrog is offline
Registered User
 
Join Date: Jan 2006
Posts: 23
Exclamation How to Split middle initial from the last name

HI
I have a excel spreadsheet where a column carries 600 users where one column carries first name and other last name other etc. In the last name column, it shows user last name with user middle name in the Capital latter.
Is there a way to separate the middile initial from the last name.

the original spreedsheet:
1 LisaM
2 JohnC
3 AlexC.
4 MichealS
5 SchwartzeR

Desire result:
1 Lisa M
2 John C
3 Alex C
4 Micheal S
5 Schwartze R

Thanks!
Reply With Quote
  #2 (permalink)  
Old 07-18-06, 21:01
mkggoh mkggoh is offline
Registered User
 
Join Date: Jun 2006
Posts: 103
Quote:
Originally Posted by arandomfrog
HI
I have a excel spreadsheet where a column carries 600 users where one column carries first name and other last name other etc. In the last name column, it shows user last name with user middle name in the Capital latter.
Is there a way to separate the middile initial from the last name.

the original spreedsheet:
1 LisaM
2 JohnC
3 AlexC.
4 MichealS
5 SchwartzeR

Desire result:
1 Lisa M
2 John C
3 Alex C
4 Micheal S
5 Schwartze R

Thanks!
Sorry, i am not very good in excel formula, especially i found it hard to debug in formula (can anyone suggest a way to debug a nested formula?), thats why i always solve problem by using vba.

For this given example, it takes me only 1 mins to write the code in vba, but it will probably take me 1 hour to find which formula to do the task (my prediction). However, someone might be good in using formula which can solve this task by using a single line of formula which i admire alot.

Here is a button i created to do this task. Try it out.

Just put all the name on column A, this press the button and your answer will be listed on column B. The computer will assume all the name will have initial in capital letter at last. if you have a name like LisaMa, u will get Lisa Ma
Attached Files
File Type: zip FilterName.zip (9.4 KB, 40 views)

Last edited by mkggoh; 07-18-06 at 21:10.
Reply With Quote
  #3 (permalink)  
Old 07-18-06, 22:21
mkggoh mkggoh is offline
Registered User
 
Join Date: Jun 2006
Posts: 103
for your convience if you know how to make a command button, below is the code for the button called cmdFilter (it will be same as the excel file that i previously posted)

Have fun

Quote:
Private Sub cmdFilter_Click()
Dim lngLastRow As String
Dim checkChar As String

lngLastRow = ActiveSheet.Range("A65536").End(xlUp).Row

For counter = 1 To lngLastRow
checkChar = Mid(ActiveSheet.Range("A" & counter).Value, Len(ActiveSheet.Range("A" & counter).Value), Len(ActiveSheet.Range("A" & counter).Value) - 1)
If Asc(checkChar) >= 65 And Asc(checkChar) <= 90 Then
ActiveSheet.Range("B" & counter).Value = Mid(ActiveSheet.Range("A" & counter).Value, 1, Len(ActiveSheet.Range("A" & counter).Value) - 1) & " " & checkChar
End If
Next
End Sub
Reply With Quote
  #4 (permalink)  
Old 07-19-06, 14:20
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Quote:
Originally Posted by arandomfrog
HI
I have a excel spreadsheet where a column carries 600 users where one column carries first name and other last name other etc. In the last name column, it shows user last name with user middle name in the Capital latter.
Is there a way to separate the middile initial from the last name.

the original spreedsheet:
1 LisaM
2 JohnC
3 AlexC.
4 MichealS
5 SchwartzeR

Desire result:
1 Lisa M
2 John C
3 Alex C
4 Micheal S
5 Schwartze R

Thanks!
As long as there isn't a period after an occasional one:

=LEFT(B2,LEN(B2)-1)

However, this takes care of the case of an occasional period:

=IF(RIGHT(B2,1)=".",LEFT(B2,LEN(B2)-2),LEFT(B2,LEN(B2)-1))
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums

Last edited by shades; 07-19-06 at 14:37.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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