从excel

时间:2018-01-25 20:14:49

标签: excel unique username generate

enter image description here如何使用名字的第一个字,参考号的最后一个和最后四个数字生成用户名,并且没有空格或破折号。

First Name: John Franklin
 Last Name: Smith Turner    
 Reference: 123456789
     Email: johns6789@example.com <--Generated email all lowercase, no space

=LEFT(A2,FIND(" ",A2)-1)&LEFT(B2,1)&RIGHT(C2,4)&"@example.com"

我尝试了以上内容,但仅适用于第一封电子邮件,但其余节目显示为#VALUE!错误

泰!

编辑:添加了截图

4 个答案:

答案 0 :(得分:2)

=LOWER(LEFT(A2,FIND(" ",A2&" ")-1)&LEFT(B2,1)&RIGHT(C2,4)&"@example.com")

enter image description here

答案 1 :(得分:0)

这对我有用:

=LOWER(IF(ISERROR(FIND(" ",A2,1)),A2,LEFT(A2,FIND(" ",A2,1)-1)))&LEFT(B2,1)&RIGHT(C2,4)&"@example.com"

答案 2 :(得分:0)

你的公式应该是:

=LOWER(LEFT($A2,IFERROR(SEARCH(" ",$A2)-1,LEN($A2)))&LEFT($B2,1)&RIGHT($C2,4)&"@example.com")

然后,您可以将其向下拖动到D列以获得所需的结果。

在这里,我将它用于我编写的测试数据:

Result

答案 3 :(得分:0)

  

为避免“单词”之间无法使用的空格,在开头或结尾处,在公式中包含一个TRIM函数

     

<强> Sub deleteCategory() With Excel.Application .ScreenUpdating = False .EnableEvents = False End With With Workbooks("your_workbook_name").Sheets("Recurring Expenses") ' do stuff like ' .copy ' .cells.select End With 'A bunch of stuff is checked and done on the now activated sheet With Workbooks("your_workbook_name").Sheets("Input") 'This is the sheet the sub is called from via a button ' Do stuff End With With Excel.Application .ScreenUpdating = True .EnableEvents = True End With End Sub