Sub mcrLastNameEmail()
'Description of project
'EXCEL macros to merge data from two colums to creat an email address.
'The data in one column has LAST NAME, First name, and
the 2nd coloumn has abc.com.
'when run, the macro will pickup the first letter of first
name
'(which starts after a "," and place it infront of last
name
'than add a "@" and pickup the data from the next column
(abc.com )to complete an email address.
'Have
x start at row 3
x
= 3
'columns
for:
col1
= 1 'full name
col2
= 2 'email
col3
= 3 'combine
'
Do
While Cells(x, col1).Value <> ""
'This will put the value of the col1 and col2 columns together,
'with a space between, and into col3
FullName = Cells(x, col1).Value
commaLocation = InStr(4, FullName, ",", 1) 'return comma location
firstLetter = Mid$(Trim(Mid$(FullName, commaLocation + 1)), 1, 1)
lastName = Trim(Mid$(FullName, 1, commaLocation - 1))
'Trim removes leading spaces
'Mid$ finds stuff in string
Cells(x, col3).Value = firstLetter + lastName + "@" + Cells(x, col2).Value
'Cells(x, col3).Value = Cells(x, col1).Value + "@" + Cells(x, col2).Value
'increase the value of x by 1 to act on the next row
x = x + 1
'Response
= MsgBox("message end", vbOKOnly, Title)
End Sub
'**************************
Result looks likes:
Name
email
Creates this column
smith, john
abc.com
jsmith@abc.com
doe, jane
abc.com
jdoe@abc.com
money, owen
test
omoney@test