Ok, I fiddled a little and all of the sudden I had a new macro named
"ParseNames"
, which is probably what you called it, Mallycat.
When I run this macro I am getting a debug window and it tells me to debug
at the the line that I enclosed with tripple asteriks *** (seventh line from
the bottom). The line is colored yellow in the de-bugger - not sure if that
means anything:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/16/2006 by kikilein
'
'
Sub ParseNames()
Dim myRange As Range
Dim myArray(2), CommaCount, X As Integer
Set myRange = Selection
For Each cell In myRange
CommaCount = 0
myArray(1) = 0
myArray(2) = 0
'count commas
If Len(cell) = 0 Then GoTo ExitHere:
For X = 1 To Len(cell)
If Mid(cell.Text, X, 1) = "," Then
CommaCount = CommaCount + 1
myArray(CommaCount) = X 'store position of comma
End If
Next X
If CommaCount = 1 Then
cell.Offset(0, 1).Value = Left(cell.Value, myArray(1) - 1)
cell.Offset(0, 2).Value = Right(cell.Value, Len(cell) - myArray(1) - 1)
Else
***cell.Offset(0, 1).Value = Left(cell.Value, myArray(1) - 1)***
cell.Offset(0, 2).Value = Right(cell.Value, Len(cell) - myArray(2) - 1)
cell.Offset(0, 3).Value = Mid(cell.Value, myArray(2) - 1, 1)
End If
ExitHere:
Next cell
End Sub