x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 238

# create an additional column in an excel spreadsheet using the current column information.

I have an excel spreadsheet that has two columns - firstname and lastname.

I need to create the third column in the format like this:

firstname.lastname@xyz.com

0
nav2567
• 2
1 Solution

Commented:
use this formula

first | Last
A1       B1

=A1&"."&B1&"@xyz.com"
0

Commented:
Here is a macro that will build the email addresses for you. You will need to customize the macro to identify the starting cells for first name, last name and resulting email address. You will also need to change xyz.com to the correct domain.

The macro shows two alternative ways of putting a value in the results column. In one statement, the code inserts a hyperlink. In the other, it inserts plain text. Pick the statement you want, and comment out the other.
``````Sub EmailAddressBuilder()
Dim rg1 As Range, rg2 As Range, rg3 As Range
Dim i As Long, n As Long
Dim ws As Worksheet
Application.ScreenUpdating = False
Set ws = ActiveSheet
With ws
Set rg1 = .Range("A2")  'First cell containing a first name
Set rg2 = .Range("B2")  'First cell containing a family name
Set rg3 = .Range("C2")  'First cell to contain an email address
Set rg1 = Range(rg1, .Cells(.Rows.Count, rg1.Column).End(xlUp))
Set rg2 = Range(rg2, .Cells(.Rows.Count, rg2.Column).End(xlUp))
End With
n = rg1.Cells.Count
For i = 1 To n
If rg1.Cells(i, 1).Value <> "" And rg2.Cells(i, 1).Value <> "" Then
'rg3.Cells(i, 1).Value = rg1.Cells(i, 1).Value & "." & rg2.Cells(i, 1).Value & "@xyz.com"                'Add plain text
End If
Next
End Sub
``````
0

Author Commented:
Thanks, guys.
0

Commented:
thanks for points... Good luck w/ project
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.