View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
kkknie[_12_] kkknie[_12_] is offline
external usenet poster
 
Posts: 1
Default Code modification - remove commas from names

This does it for me.

Code
-------------------
For Each cell In Range("A1:A10")
If Not IsEmpty(cell) Then
If InStr(cell, ",") Then
sStr = Right(cell, Len(cell) - InStr(cell, ","))
If InStr(cell, " ") Then
sStr = Trim(sStr)
sStr = Left(sStr, InStr(sStr, " ") - 1)
End If
cell.Value = Trim(sStr) & " " & Trim(Left(cell, InStr(cell, ",") - 1))
End If
Else
Exit For
End If
Nex
-------------------

One item to mention is that I wouldn't use the variable cell in you
code since it is so close to an actual defined object (in fact, I'
suprised excel let you get away with it). Just a tip to avoi
confusion later if you start using the Cells range object.



--
Message posted from http://www.ExcelForum.com