Sub leerArchivoTexto()
Dim archivo As String 'ruta y nombre del archivo
Dim texto As String 'línea de texto a leer
Dim fila As Integer 'fila en la hoja de trabajo y número de línea en el texto
'Abrir el archivo
archivo = "C:\Users\Juan Carlos Terrazas\Desktop\LPA\lin_pm19_a1_3.txt"
Open archivo For Input As #1 'leer un archivo de texto por el canal #1
fila = 0
'Leer y procesar el contenido del archivo
While Not EOF(1) 'la función EOF regresa verdadero al llegar al final del archivo
Line Input #1, texto 'lee cada una de las líneas del archivo y las almacena en la variable texto
fila = fila + 1
Cells(fila, 1).Value = texto
'Reconocer ultima fila de nodo conectores
Dim Rec As Integer 'Variable que almacena fila de ultimo nodo conector
If InStr(Cells(fila, 1), "C") <> 0 And InStr(Cells(fila, 1), "(") <> 0 Then
If InStr(Cells(fila - 1, 1), "C") <> 0 And InStr(Cells(fila - 1, 1), "(") <> 0 Then
If InStr(Cells(fila + 1, 1), "C") = 0 And Cells(fila + 1, 1) <> Empty Then
Rec = fila
End If
End If
End If
Wend
'Cerrar el archivo de entrada
Close #1
'Eliminar Rango desde A1 hasta fila ultimo nodo conector
Workbooks("Libro1.xlsm").Activate
Worksheets("Hoja1").Select
Range("A1:A" & Rec).Select
Selection.Delete Shift:=xlUp
'Reconocer ultima fila con datos
Dim ult As Integer
ult = Cells(Rows.Count, 1).End(xlUp).Row
'Separar Texto de columna A en distintas columnas
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(6, 1), Array(12, 1), Array(18, 1), Array(28, 1), _
Array(38, 1), Array(48, 1), Array(58, 1)), TrailingMinusNumbers:=True
'Recorre desde la ultima fila con informacion hasta abajo y elimina filas que no corresponden a arcos
For i = ult To 1 Step -1
If Cells(i, 1) = Empty Or IsNumeric(Cells(i, 1)) = False Or Cells(i, 1) = 1 Then
Rows(i).Select
Selection.Delete Shift:=xlUp
End If
Next
'Cambia los puntos por comas
Cells.Select
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub