Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Leading Characters If String Is Only 7 Characters Paperback Writer Excel Discussion (Misc queries) 2 April 21st 09 09:07 PM
Insert characters into String franciz Excel Programming 4 May 11th 08 07:54 AM
Macro to delete row based on criteria (first few characters of string) [email protected] Excel Programming 5 May 15th 06 06:11 PM
use macro to insert characters at the beginning of a string dcmackie Excel Programming 4 April 4th 05 12:35 AM
Insert characters in a text string jamae918 Excel Worksheet Functions 1 March 28th 05 10:04 PM


All times are GMT +1. The time now is 05:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"