Delete everything except the email address on each line...

G

Gordon

Hi

I have 1900 lines of information. Each one begins with a persons name,
followed by a random gap then followed by an email address. What I need is
just the email addresses. SO the macro needs to look at each line. Identify
where the persons name ends, delete, delete the space afterwards, and leave
the email address intact.

Any help appreciated. I know excel VB, not Word!

Thanks Gordon
 
D

DaveLett

Hi Gordon,
You don't NEED a macro to get this done; instead, you can use a wildcard
search and replace. Open the Find and Replace dialog box, select the Use
Wildcards check box, and place the following in the Find what box:

[A-z]{1,}

Leave the Replace with box empty. Do a Replace All.

HTH,
Dave

P.S. If this must be a macro, just let me know.
 
G

Gordon

Hi Dave

Is there a Macro too...? (please?)

G

DaveLett said:
Hi Gordon,
You don't NEED a macro to get this done; instead, you can use a wildcard
search and replace. Open the Find and Replace dialog box, select the Use
Wildcards check box, and place the following in the Find what box:

[A-z]{1,}

Leave the Replace with box empty. Do a Replace All.

HTH,
Dave

P.S. If this must be a macro, just let me know.

Gordon said:
Hi

I have 1900 lines of information. Each one begins with a persons name,
followed by a random gap then followed by an email address. What I need is
just the email addresses. SO the macro needs to look at each line. Identify
where the persons name ends, delete, delete the space afterwards, and leave
the email address intact.

Any help appreciated. I know excel VB, not Word!

Thanks Gordon
 
D

DaveLett

Hi Gordon,

I think this is what you're looking for:
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.text = "[A-z]{1,} {1,}"
.MatchWildcards = True
With .Replacement
.ClearFormatting
.text = ""
End With
.Execute Replace:=wdReplaceAll
End With
End With


Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top