Text manipulation macros |
|||
|
|||
Sub MacroToSeperateNames() 'define the starting row x=2 'start the loop and continue till you encounter a blank cell in column A and row 2 Do While Cells(x,1)<> "" 'define a variable myStr and set its data type Dim myStr As String 'initialize the string myStr="Good Day!" myStr=Cells(x,1) 'check the position of the blank MyPos=InStr(myStr, " ") 'Extact characters from left of the string upto the blank space and then minus 1 for the blank space Cells(x,2)=Left(myStr, MyPos-1) 'extract characters from name starting from (blank+1) to avoid getting blank also Cells(x,3)=Mid(myStr, (MyPos+1)) x=x+1 Loop End Sub |
|||