View Single Post
  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming
Cheker Cheker is offline
external usenet poster
 
Posts: 15
Default splitting names & email add.

Thanks Norman,
I'll give it a try and turn back to here...

"Norman Jones" wrote in message
...
Hi Cheker:

Assume your names and email addresses start in A1, try:

Sub Tester2()
Dim rng As Range, rCell As Range
Dim pos1 As Long, pos2 As Long
Dim sStr As String
Dim sh As Worksheet
Set sh = Sheets("Sheet1") '<<======== CHANGE

With sh
Set rng = Range(.Range("A1"), _
.Cells(Rows.Count, "A").End(xlUp))
End With

For Each rCell In rng
pos1 = InStr(rCell.Value, " ")
pos2 = InStrRev(rCell.Value, " ")
rCell(1, 2).Value = Left(rCell.Value, pos1 - 1)
sStr = Mid(rCell.Value, pos2 + 1)
ActiveSheet.Hyperlinks.Add _
Anchor:=rCell(1, 3), _
Address:="mailto:" & sStr, TextToDisplay:=sStr
Next
rng.Delete shift:=xlToLeft
End Sub


---
Regards,
Norman



"Cheker" wrote in message
...
Hi,

I remember reading a code for splitting names and email addresses from a
*.txt file using (via importing) excel. But forget the content...

The source *.txt file is in the format such as:
----------------------------------------
marry chris
adam kenny

...
..
etc

I need to split the two info into two adjacent columns such as:
column 1 having the name & surname info ONLY
column 2 having the email address info ONLY
-----------------
Hope experts could remind me the way.
Sincerely