Thread: [Solved] vbc code
View Single Post
 
Old 09-13-2011, 11:11 AM
rajpeter rajpeter is offline Windows XP Office 2003
Novice
 
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