johnmerlino
Board Regular
- Joined
- Sep 21, 2010
- Messages
- 94
Hey all,
When I currently try to run the below macro, I get a syntax error. Basically it performs excel formulas to split names:
I replaced what it initially generated with the below formulas because whatever it was generating when I recorded the macro and executed below formulas, later on it would not work with other spreadsheets, so I copied the actual formulas themselves into the macro but now I get the error:
Thanks for response.
When I currently try to run the below macro, I get a syntax error. Basically it performs excel formulas to split names:
Code:
Sub nameSplitter_Improved()
'
' nameSplitter_Improved Macro
'
'
Windows("summary_judgment.xlsx").Activate
Range("C1").Select
ActiveCell.FormulaR1C1 = "=LEFT(C1,FIND(" ",C1)-1)"
Range("D1").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERR(MID(C1,FIND(" ",C1)+1,IF(ISERR(FIND(" ",C1,FIND(" ",C1)+1)), FIND(" ",C1),FIND(" ",C1,FIND(" ",C1)+1))-FIND(" ",C1)-1)),"",MID(C1,FIND(" ",C1)+ 1,IF(ISERR(FIND(" ",C1,FIND(" ",C1)+1)),FIND(" ",C1),FIND(" ",C1,FIND(" ",C1)+1))-FIND(" ",C1)-1))"
Range("E1").Select
ActiveCell.FormulaR1C1 = _
"=RIGHT(C1,LEN(C1)-FIND("*",SUBSTITUTE(C1," ","*",LEN(C1)-LEN(SUBSTITUTE(C1," ","")))))"
Range("C1").Select
Selection.AutoFill Destination:=Range("C1:C227")
Range("C1:C227").Select
Range("D1").Select
Selection.AutoFill Destination:=Range("D1:D227")
Range("D1:D227").Select
Range("E1").Select
Selection.AutoFill Destination:=Range("E1:E227")
Range("E1:E227").Select
Columns("C:E").Select
Columns("C:E").Copy
Columns("F:H").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("C:E").Select
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Rows("1:1").Select
Range("B1").Activate
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B1").Select
ActiveCell.FormulaR1C1 = "first_name"
Range("C1").Select
ActiveCell.FormulaR1C1 = "middle_initial"
Range("D1").Select
ActiveCell.FormulaR1C1 = "last_name"
Range("E1").Select
End Sub
Code:
=LEFT(C1,FIND(" ",C1)-1)
Code:
=IF(ISERR(MID(C1,FIND(" ",C1)+1,IF(ISERR(FIND(" ",C1,FIND(" ",C1)+1)), FIND(" ",C1),FIND(" ",C1,FIND(" ",C1)+1))-FIND(" ",C1)-1)),"",MID(C1,FIND(" ",C1)+ 1,IF(ISERR(FIND(" ",C1,FIND(" ",C1)+1)),FIND(" ",C1),FIND(" ",C1,FIND(" ",C1)+1))-FIND(" ",C1)-1))
Code:
=RIGHT(C1,LEN(C1)-FIND("*",SUBSTITUTE(C1," ","*",LEN(C1)-LEN(SUBSTITUTE(C1," ","")))))