NO PUEDO ENCONTRAR LA MANERA PARA SEPARAR DE UNA CELDA EL APELLIDO Y QUE LO INSERTE EN LA CELDA SIGUIENTE Y QUE EN LA CELDA ORIGINAL DEJE SOLAMENTE EL NOMBRE/S.
ESPERO HABER SIDO CLARO
SALUDOS Y GRACIAS POR SU AYUDA



Sub SeparaNombres()
' Separa Nombres con división "/" en columnas con encabezado
' Posicionarse en la primera celda a separar
' Macro recorded 02/10/2004 ByPaco
' actualizada el 01/09/2005 daba error, si los datos estaban al tope superior de la hoja
' 22/08/2006 Se agregó la opción para poder elegir un separador
'Solicita un separador
Sepa = InputBox("Escriba aquí el tipo de separador que usa para distinguir Nombres de apellidos", "Separador de Nombres", "/")
If Sepa = " " Or Sepa = "" Or Sepa = " " Then msg = MsgBox("No se permiten espacios", vbOKOnly, "¡¡ A T E N C I í“ N !!")
If msg = vbOK Then GoTo fin 'Si el separador es un espacio o no pone nada termina el proceso
If Cells(ActiveCell.Row, ActiveCell.Column).Value = Empty Then GoTo fin
'Insera tres columnas una para nombre(s) y dos para los apellidos
ActiveCell.EntireColumn.Insert
ActiveCell.EntireColumn.Insert
ActiveCell.EntireColumn.Insert
Cells(ActiveCell.Row, ActiveCell.Column + 3).Select 'Se posiciona en la primera celda despues de las columnas insertadas
Range(Selection, Selection.End(xlDown)).Select 'Selecciona toda la cadena de filas
'Realiza la separación
Selection.TextToColumns Destination:=Cells(ActiveCell.Row, ActiveCell.Column - 3), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Space:=False, Other:=True, OtherChar:=Sepa, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1))
Selection.EntireColumn.Delete 'Borra la última columna
On Error GoTo Ins 'si causa error por no tener vacia la celda superior, inserta una
ActiveCell.Offset(-1, 0).Range("A1").Select
Ins:
If Err = 1004 Then
Selection.End(xlUp).Select
Selection.EntireRow.Insert
Cells(ActiveCell.Row, ActiveCell.Column).Select
End If
'Pone los encabezados de las columnas
On Error Resume Next
ActiveCell.Offset(0, -3).Range("A1").Select
ActiveCell.FormulaR1C1 = InputBox("Primer encabezado, normalmente Apellido Paterno", "Encabezado", "Ap.Paterno")
ActiveCell.Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = InputBox("Segundo encabezado, normalmente Apellido Materno", "Encabezado", "Ap.Materno")
ActiveCell.Columns("A:A").EntireColumn.EntireColumn.AutoFit
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = InputBox("Tercer encabezado, normalmente Nombre(s)", "Encabezado", "Nombre(s)")
ActiveCell.Columns("A:A").EntireColumn.EntireColumn.AutoFit 'Ajusta el ancho del rango
'Termina el proceso
fin:
End Sub






galileogali";p="39215 escribió:KL: estoy tratando de entender sin lograrlo.
Words devuelve una matriz horizontal formada por tantos elementos como palabras haya, No obstante no entiendo cómo funciona...
Cuando tengas un poco de tiempo....
Function Split(sStr As Variant, sdelim As String) As Variant
Split = Evaluate("{""" & Application.Substitute(sStr, sdelim, """,""") & """}")
End Function 




Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 6 invitados