Câu hỏi

28/05/2013 07:33
Anh/chị có biết hàm nào trong Microsoft Excel tách được họ tên ra không?
Danh sách câu trả lời (1)

Bạn có thể sử dụng các hàm có sẵn trong Microsoft Excel để thực hiện yêu cầu. Ví dụ dưới đây là 2 hàm tách tên, họ+chữ lót.
Function ExtractFirstName(strFullName As String) As String
Dim strTemp As String
Dim i As Integer
Dim l As Integer
strTemp = strFullName
l = Len(strFullName)
If l > 0 Then
i = 0
If InStr(1, strFullName, " ", vbTextCompare) Then
Do
i = i + 1
Loop Until Mid(strFullName, l - i, 1) = " "
strTemp = Right(strFullName, i)
Else
End If
Else
strTemp = ""
End If
ExtractFirstName = strTemp
End Function
Function ExtractLastMiddleName(strFullName As String) As String
Dim strTemp As String
Dim i As Integer
Dim l As Integer
strTemp = strFullName
l = Len(strFullName)
i = 0
If InStr(1, strFullName, " ", vbTextCompare) Then
Do
i = i + 1
Loop Until Mid(strFullName, l - i, 1) = " "
strTemp = Left(strFullName, l - i)
Else
strTemp = ""
End If
ExtractLastMiddleName = strTemp
End Function
Function ExtractFirstName(strFullName As String) As String
Dim strTemp As String
Dim i As Integer
Dim l As Integer
strTemp = strFullName
l = Len(strFullName)
If l > 0 Then
i = 0
If InStr(1, strFullName, " ", vbTextCompare) Then
Do
i = i + 1
Loop Until Mid(strFullName, l - i, 1) = " "
strTemp = Right(strFullName, i)
Else
End If
Else
strTemp = ""
End If
ExtractFirstName = strTemp
End Function
Function ExtractLastMiddleName(strFullName As String) As String
Dim strTemp As String
Dim i As Integer
Dim l As Integer
strTemp = strFullName
l = Len(strFullName)
i = 0
If InStr(1, strFullName, " ", vbTextCompare) Then
Do
i = i + 1
Loop Until Mid(strFullName, l - i, 1) = " "
strTemp = Left(strFullName, l - i)
Else
strTemp = ""
End If
ExtractLastMiddleName = strTemp
End Function
Trả lời câu hỏi
Câu hỏi lĩnh vực Câu hỏi khác
Rao vặt Siêu Vip