VBA Script to extract and assemble email address

jeffkahn1

New Member
Joined
Dec 15, 2011
Messages
4
I have a 500 row Excel table that I need to figure out a script for.

Column 1: First Name
Column 2: Last Name
Column 3: Employer
Column 4: Email (I want this to autofill based on a VBA script)

Assuming a known given email syntax for "COMPANY" - firstname.lastname@company.com, and my columns are:

Column 1: Joe
Column 2: Smith
Column 3: Company

Does anyone have an example of a script that can autopopulate Column 4 based on a set of known email syntax?

Thanks in advance - Jeff
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Welcome to Mr Excel Forum.

Try script below

Code:
Sub Test()
 
    With Range("D2:D" & Cells(Rows.Count, "A").End(xlUp).Row)
        .Formula = "=LOWER(A2&"".""&B2&""@""&C2&"".com"")"
        .Value = .Value
    End With
 
End Sub

Biz
 
Upvote 0
Thanks for the reply, and I think I understand your formula.

That said, my text in Column 3 (employer) might read "GE Water & Sensors", and from experience I know that their emails syntax is firstname.lastname@ge-ws.com. With your example, the email string would be firstname.lastname@GE Water & Sensors.com.

Instead, I need the VBA code to check the text in Column 3 for known strings (i.e. "GE Water"), and if it finds a known string with a known complimentary email syntax (I imagine lots of "IF" statements), to autofill a proper email into Column 4.

Thanks - Jeff
 
Upvote 0
Can you give all different company name combination and anything out of ordinary?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>

For Example,

Air India Airlines
Hindustan Unilever
Nokia Ltd

Another alternative set-up a table with Company name and short name you will use in e-mail. Utilise vlookup to get short name for email address.

Biz
 
Upvote 0
Biz,

I've pulled back from trying to get this to work for right now. I'm going to play around with the code over the holidays, will report back if I still can't get it to work... Thanks.
 
Upvote 0
Biz,

I've pulled back from trying to get this to work for right now. I'm going to play around with the code over the holidays, will report back if I still can't get it to work... Thanks.

Kwel. I am going on vacation soon so I may be I can answer your question next year.

Biz
 
Upvote 0

Forum statistics

Threads
1,215,136
Messages
6,123,247
Members
449,093
Latest member
Vincent Khandagale

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