Hi,
 
Try this.. 
 
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Value <> "" and Target.Column=6 Then
        Target.Value = BreakName(Target.Value)
    End If
End Sub
Function BreakName(ByVal strName As String)
    BreakName = Split(strName, " ")(1) & " " & Split(strName, " ")(0)
End Function
 
Regards,
Lalit Mohan

On Wednesday, 27 June 2012 16:26:09 UTC+5:30, sharath chandra wrote: 
>
> Hi Lalit, 
>
> Thank you for your quick response. I think we are almost there.
>
> When I enter a value say my first name and last name, it is displaying 
> last name and first name. But, immediately it shows a run-time error 13, 
> type mismatch.
>
> I need this in column F. So if I add an additional statement If 
> Target.Column=6 and then your code will it work?
>
> Thanks again.
> Sharath
>
> On Wednesday, June 27, 2012 3:38:12 PM UTC+5:30, Lalit_Mohan wrote: 
>>
>> Hi,
>>  
>> Try this on sheet selection change event
>>  
>>  
>> Option Explicit
>> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>>     If Target.Value <> "" Then
>>         Target.Value = BreakName(Target.Value)
>>     End If
>> End Sub
>> Function BreakName(ByVal strName As String)
>>     BreakName = Split(strName, " ")(1) & " " & Split(strName, " ")(0)
>> End Function
>>  
>> Regards,
>> Lalit Mohan
>>
>> On Wednesday, 27 June 2012 15:21:32 UTC+5:30, sharath chandra wrote:
>>
>>>
>>> Hello Experts, 
>>>
>>> I need a quick VBA code. We have column where we enter a name in "First 
>>> Name Last Name" format. When someone enters a name in that cell, it should 
>>> automatically display the name in the same cell in the "Last Name, First 
>>> Name" format (which is Outlook format).
>>>
>>> Please let me know if anything is unclear.
>>>
>>> Thank you,
>>> Sharath
>>>
>>

-- 
-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com


Reply via email to