Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2011, 11:11 AM
rajpeter rajpeter is offline vbc code Windows XP vbc code Office 2003
Novice
vbc code
 
Join Date: Sep 2011
Posts: 6
rajpeter is on a distinguished road
Default vbc code

hi
this is the code i found out from the web


how to make
RAJ PETER SHOUld show Raj Peter

HTML Code:
Sub macro1()
 Dim firstName As String
    Dim lastName As String
    Dim n As Integer
    Dim rowNum As Integer
    Dim colNum As Integer
    rowNum = 1
    colNum = 1
    
    While Cells(rowNum, colNum).Value <> ""
        n = InStr(1, Cells(rowNum, colNum).Value, ",")
        lastName = Left(Cells(rowNum, colNum).Value, n - 1)
        firstName = Right(Cells(rowNum, colNum).Value, Len(Cells(rowNum, colNum).Value) - n - 1)
        Cells(rowNum, colNum + 1).Value = firstName
        Cells(rowNum, colNum + 2).Value = lastName
        rowNum = rowNum + 1
    Wend
End Sub
Reply With Quote
  #2  
Old 09-13-2011, 02:16 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline vbc code Windows 7 32bit vbc code Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Hi,

You probably don't need VBA for this.

If RAJ PETER is in cell A1, then this formula will return Raj Peter

=PROPER(A1)

Is that something you can work with?
Reply With Quote
  #3  
Old 09-13-2011, 02:29 PM
rajpeter rajpeter is offline vbc code Windows XP vbc code Office 2003
Novice
vbc code
 
Join Date: Sep 2011
Posts: 6
rajpeter is on a distinguished road
Default

thanks but it is not only A1 IT has more than 1000 names and i have vb code find out last name and first name it works the above code. but i have the cell RAJ PETER Full upper case but i want the first letter should be upper case exampel Raj Peter
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to add dates terricritch Excel Programming 10 11-08-2011 09:51 AM
vba code in excel rajpeter Excel Programming 5 09-11-2011 06:13 PM
vbc code Fastest way to run a code b0x4it Word VBA 4 05-18-2011 07:54 PM
FileSaveAs with Code bsmith Office 0 01-05-2006 08:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft