Modificar Macros para exportar excel a Txt separado con comas
Hay una macro me gustaría que me ayuden a modificar, lo que deseo es que al abrir mi formulario en la "hoja 1" me exporte datos que están en la "hoja2" en un rango por defecto rango de "A1:D50" automáticamente. Adjunto la macros mencionada.
Private Sub EXPORTAR_Click()
Const DELIMITER As String = ","
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
nFileNum = FreeFile
ruta = ThisWorkbook.Path
ChDir ruta
Open "REPORTE.txt" For Output As #nFileNum
For Each myRecord In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells, _
Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
MsgBox "Se ha Exportado Correctamente!!! ", vbInformation, "EXPORTAR"
End Sub