Hi,
I have an UserForm; have written the below VBA code to create email Id from the form entries - firstname & lastname; eg: first name : Ravi last name: Kumar then it creates the email ID as ravi.kumar@abc.com.
I need the VBA code that checks the user entries first & lastname and if the entry is duplicate it has to create an email id suffixing 1,2... say for ex: Ravi Kumar is entered again, it has to create the email ID as ravi.kumar1@abc.com.
Dim fname As String
Dim lname As String
Dim pro As String
Dim FullName As String
Dim mail As String
Dim RwCnt As Long 'to get the last filled row in the sheet
Dim ws As Worksheet
Set ws = Worksheets("Data")
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row 'go to sheet, got to last row & first column
fname = UserForm2.TextBox1.Value
lname = UserForm2.TextBox2.Value
pro = UserForm2.TextBox3.Value
FullName = fname & " " & lname
mail = fname & "." & lname & "@abc.com"
Thanks.
Bookmarks