![]() |
Macro to insert a period for single characters in a string
I want a macro to insert a peroid after any single alpha character in a list of names in a column. I have a list of names but single alpha characters such as middle initials don't have a period after it. Can this be done? |
Macro to insert a period for single characters in a string
With your names in ColA; try the below macro Sub Macro() lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row For lngRow = 1 To lngLastRow arrData = Split(Range("A" & lngRow), " ") For intTemp = 0 To UBound(arrData) If Len(arrData(intTemp)) = 1 Then arrData(intTemp) = arrData(intTemp) & "." End If Next Range("A" & lngRow) = Join(arrData, " ") Next End Sub If this post helps click Yes --------------- Jacob Skaria "Aposto" wrote: I want a macro to insert a peroid after any single alpha character in a list of names in a column. I have a list of names but single alpha characters such as middle initials don't have a period after it. Can this be done? |
Macro to insert a period for single characters in a string
Thanks works like a charm! "Jacob Skaria" wrote: With your names in ColA; try the below macro Sub Macro() lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row For lngRow = 1 To lngLastRow arrData = Split(Range("A" & lngRow), " ") For intTemp = 0 To UBound(arrData) If Len(arrData(intTemp)) = 1 Then arrData(intTemp) = arrData(intTemp) & "." End If Next Range("A" & lngRow) = Join(arrData, " ") Next End Sub If this post helps click Yes --------------- Jacob Skaria "Aposto" wrote: I want a macro to insert a peroid after any single alpha character in a list of names in a column. I have a list of names but single alpha characters such as middle initials don't have a period after it. Can this be done? |
All times are GMT +1. The time now is 12:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com