PDA

View Full Version : VBA Macro To Convert Text To Proper Case



Howardc
05-30-2013, 01:25 PM
I have data in Col E. I would like a macro to convert the text from row 2 onwards into proper case

Excel Fox
05-30-2013, 03:45 PM
Sub ConvertToProper()

Dim lng As Long
lng = Cells(Rows.Count, "E").End(xlUp).Row
Range("E2:E" & lng).Value = Evaluate("=IF(E2:E" & lng & "<>"""",PROPER(E2:E" & lng & "),"""")")

End Sub

Howardc
05-30-2013, 07:18 PM
Thanks for the help, much appreciated

Rick Rothstein
05-30-2013, 10:26 PM
Sub ConvertToProper()
Dim lng As Long
lng = Cells(Rows.Count, "E").End(xlUp).Row
Range("E2:E" & lng).Value = Evaluate("=IF(E2:E" & lng & "<>"""",PROPER(E2:E" & lng & "),"""")")
End Sub
You can shorten that Evaluate statement slightly by doing it this way...

Sub ConvertToProper()
Dim lng As Long
lng = Cells(Rows.Count, "E").End(xlUp).Row
Range("E2:E" & lng).Value = Evaluate("IF(ROW(),PROPER(E2:E" & lng & "))")
End Sub

Howardc
05-31-2013, 12:38 AM
Hi Rick, thanks for your input-much appreciated