extracting text from a field

steven H

Board Regular
Joined
Feb 19, 2002
Messages
66
I have 2000 fields in a column, with garbled text in them apart from an email address in each which I want to extract, in each case the e-mail address is surrounded by< > how would I extract the address only to another field

ie in A1

fjdhflkjsjdhjaldhskj<myemail@blahblah.co.uk>hbjiduegduqhuhwd

i wantin A2 myemail@blahblah.co.uk

any help would be appreciated
This message was edited by steven H on 2002-03-27 10:04
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hiya,

The formula below should do the trick (although I have a feeling it could probably be simplified)...

=MID(A1,FIND("<",A1)+1,FIND(">",A1)-FIND("<",A1)-1)

Rgds
AJ
 
Upvote 0
On 2002-03-27 10:03, steven H wrote:
I have 2000 fields in a column, with garbled text in them apart from an email address in each which I want to extract, in each case the e-mail address is surrounded by< > how would I extract the address only to another field

ie in A1

fjdhflkjsjdhjaldhskj<myemail@blahblah.co.uk>hbjiduegduqhuhwd

i wantin A2 myemail@blahblah.co.uk

any help would be appreciated
This message was edited by steven H on 2002-03-27 10:04

=MID(A1,SEARCH("<",A1)+1,SEARCH(">",A1)-SEARCH("<",A1)-1)
 
Upvote 0
Aladin

Thats worked fine thanks for the prompt reply, but the problem is (AS I JUST FOUND OUT) there may be more than one e-mail address within the field breacketed <> in the same way and I need to return both....
 
Upvote 0
On 2002-03-27 10:25, steven H wrote:
Aladin

Thats worked fine thanks for the prompt reply, but the problem is (AS I JUST FOUND OUT) there may be more than one e-mail address within the field breacketed <> in the same way and I need to return both....

Note that AJ's formula is identical to the one I posted.

In B1 enter:

=MID(A1,SEARCH("<",A1)+1,SEARCH(">",A1)-SEARCH("<",A1)-1)

[which you are already given ]

In C1 enter:

=IF(LEN(A1)-LEN(SUBSTITUTE(A1,"<",""))>1,SUBSTITUTE(A1,"<"&B1&">",""),"")

In D1 enter:

=IF(LEN(C1),MID(C1,SEARCH("<",C1)+1,SEARCH(">",C1)-SEARCH("<",C1)-1),"")

Repeat the logic of the above if you have more than 2 emails buried in A1.

Aladin
 
Upvote 0
Seems like a lot of people here don't like VBA solutions, but here's one if you want it.

This subroutine would put all email addy's in A2, with a space between them.

Private Sub GetEmail()
Dim intCnt As Integer, _
intLen As Integer
Dim strChar As String, _
strData As String, _
strEmail As String
Dim blnFound As Boolean

strData = ActiveSheet.Range("A1")
intLen = Len(strData)
For intCnt = 1 To intLen
strChar = Mid(strData, intCnt, 1)
If strChar = "<" Then
blnFound = True
ElseIf strChar = ">" Then
blnFound = False
strEmail = strEmail & " "
ElseIf blnFound Then
strEmail = strEmail & strChar
End If
Next intCnt

ActiveSheet.Range("A2") = strEmail
End Sub

I just through this together, but it should work.
 
Upvote 0
You could try... Find and replace each sign; greater than (>) and less than (<) with a character like ( | ). (Obviously not a letter or @ sign that resides in your text.)
Then choose Text to Columns, delimited, other (put in the character you chose | ). You have options such as skipping a column and choosing a destination cell.

HTH
Drew
 
Upvote 0
On 2002-03-27 11:11, LarryJ wrote:
Seems like a lot of people here don't like VBA solutions, but here's one if you want it.

I love VBA solutions. I care not one jot for builtin functions. (except for SUM)
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,034
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top