Código:
Sub Exportar_Seleccion_a_TXT()
Dim R As Range
Dim Ruta As String, Archivo As String
Dim Fila As Range, Celda As Range
If TypeName(Selection) <> "Range" Then
MsgBox "Seleccioná un rango antes de ejecutar la macro.", vbExclamation
Exit Sub
End If
Set R = Selection
Ruta = ThisWorkbook.Path & "\"
Archivo = Ruta & "Exportado_" & Format(Now, "yyyymmdd_hhmmss") & ".txt"
Open Archivo For Output As #1
For Each Fila In R.Rows
Dim linea As String: linea = ""
For Each Celda In Fila.Cells
linea = linea & Celda.Value & vbTab
Next Celda
linea = Left(linea, Len(linea) - 1)
Print #1, linea
Next Fila
Close #1
MsgBox "TXT creado correctamente:" & vbCrLf & Archivo
End Sub
⭐ Si te gustó, por favor regístrate en nuestra Lista de correo y Suscríbete a mi canal de YouTube para que estés siempre enterado de lo nuevo que publicamos.