Use these formulas:
=SEERRO(ESQUERDA($A3;LOCALIZAR(" ";$A3;1));$A3)
=SEERRO(DIREITA($A3;NÚM.CARACT($A3)-LOCALIZAR(" ";$A3;1));"")
If there is an error in the left part of the name, the value of column A will be written.
And if there is an error in the right part of the name, it will be written "" or Blank
Update
A UDF (User Defined Function) can be used to perform these operations.
Just put the function inside a VBA module.
Code
Function EXTRACTELEMENT(Txt As String, n, Separator As String) As String
On Error GoTo ErrHandler:
EXTRACTELEMENT = Split(Application.Trim(Mid(Txt, 1)), Separator)(n - 1)
Exit Function
ErrHandler:
' error handling code
EXTRACTELEMENT = CVErr(xlErrNA)
On Error GoTo 0
End Function
After inserting into the module you can use it in the worksheet as follows:
Data is entered with =EXTRACTELEMENT("String para separar ou célula com a String"; "Número do Elemento"; "separador(- .,:)")
The cell A1
has the desired entry, you can use the =EXTRACTELEMENT($A$1;1;"-")
function in cell B1
and =EXTRACTELEMENT($A$1;2;"-")
in cell B2
and so on.
The result:
Description:
Thedescriptioncanbeaddedbyrunningthefollowingcodeonce:
SubDescribeFunction()DimFuncNameAsStringDimFuncDescAsStringDimCategoryAsStringDimArgDesc(1To3)AsStringFuncName="EXTRACTELEMENT"
FuncDesc = "Returns the nth element of a string that uses a separator character/Retorna o enésimo elemento da string que usa um caractér separador."
Category = 7 'Text category
ArgDesc(1) = "String that contains the elements/String que contém o elemento"
ArgDesc(2) = "Element number to return/ Número do elemento a retornar"
ArgDesc(3) = "Single-character element separator/ Elemento único separador (spc por padrão)"
Application.MacroOptions _
Macro:=FuncName, _
Description:=FuncDesc, _
Category:=Category, _
ArgumentDescriptions:=ArgDesc
End Sub