如果您想使用 Excel 函数:请查看这些
Split text using Left, Mid, Right, in excel formulas 这里有很多例子。
这将为您提供公式中的电子邮件用户名:
对于本例,电子邮件位于 B2 中
D2 =LEFT(B2, SEARCH("@",B2,1)-1)
'The -1 at the end removes the @ symbol.
E2 =RIGHT(B2,LEN(B2)-SEARCH("@",B2,1))
一些有用的链接:
INDIRECT :返回公式内的引用。
CONCATENTATE :允许您将字符串混合在一起
连接的两个例子:
您当然可以省略“”,即在两个文本值之间添加一个空格。
A1 = Harry
B1 = Smith
C1 = Concatenate(A1, " ", B1) 'Result = "Harry Smith"
or
C1 = A1 & " " & B1 'Result = "Harry Smith"
C1 = A1 & B1 'Result = "HarrySmith"
在 VBA 中,只需接受并修改它。 使用拆分,您几乎可以构建任何您需要的东西。最初这个问题是用 VBA 标记的,所以我将把它留在答案中,尽管因为该标记已被删除:
Sub Splitter()
Dim tempValue As String
Dim tempUser As String
Dim emailParts() As String
tempValue = Sheets("Sheet1").Cells(1, 1)
emailParts() = Split(tempValue, "@")
tempUser = emailParts(0)
Sheets("Sheet1").Cells(2, 1) = tempUser
Sheets("Sheet1").Cells(3, 1) = "You can blend " & tempUser & " with any text"
End Sub