converting email address formats

R

rlpetrie12

How do I write a macro to convert one email format to another. i.e.,
(e-mail address removed) to (e-mail address removed) (the first and last names are
capitalized and need to be first letter of first name combined with last
name, all lowercase and change the multiple email providers and extensions to
"@usuhs.edu"?
 
J

Jacob Skaria

Try

=LOWER(LEFT(A1,1) & MID(REPLACE(A1,FIND("@",A1),255,"@usuhs.edu"),
FIND(".",A1)+1,255))

If this post helps click Yes
 
D

David Biddulph

=LOWER(LEFT(A1)&MID(A1,FIND(".",A1)+1,FIND("@",A1)-FIND(".",A1)-1))&"@usuhs.edu"
 
G

Gary''s Student

Select the cell and run:

Sub remailit()
Set r = ActiveCell
nw = "usuhs.edu"
v = ActiveCell.Value
s = Split(v, ".")
s(0) = Left(s(0), 1)
v = Join(s, ".")
t = Split(v, "@")
t(1) = nw
r.Value = Join(t, "@")
End Sub
 
R

Ron Rosenfeld

How do I write a macro to convert one email format to another. i.e.,
(e-mail address removed) to (e-mail address removed) (the first and last names are
capitalized and need to be first letter of first name combined with last
name, all lowercase and change the multiple email providers and extensions to
"@usuhs.edu"?

To enter this Macro (Sub), <alt-F11> opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this Macro (Sub), first select the range to be processed.

Then <alt-F8> opens the macro dialog box. Select the macro by name, and <RUN>.

As written, the macro works on "Selection" and writes the result in the
adjacent cell. This can be altered. IT also does not test to see if the
initial email is properly formed. If not, it will just duplicate the contents
of the data cell. This can be changed, but you'll have to determine what you
want to happen.

====================================
Option Explicit
Sub NewEmail()
Dim c As Range
Dim rg As Range
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "(^.)[^.]*\.([^@]+)(.*$)"

Set rg = Selection 'or whatever
For Each c In rg
c.Offset(0, 1).Value = LCase(re.Replace(c.Value, "[email protected]"))
Next c
End Sub
====================================
--ron
 

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