Private Sub Data2txtFile(ByVal Range2Export As Range, ByVal txtFile As String)
Dim aSource, tmp(), arr(), lR As Long, lC As Long
On Error GoTo ExitSub
aSource = Range2Export.Value
If UCase(Right(txtFile, 4)) <> ".TXT" Then txtFile = txtFile & ".txt"
ReDim tmp(1 To UBound(aSource, 2))
ReDim Arr(1 To UBound(aSource, 1))
With CreateObject("Scripting.FileSystemObject")
With .CreateTextFile(txtFile, True, True)
For lR = 1 To UBound(aSource, 1)
For lC = 1 To UBound(aSource, 2)
tmp(lC) = aSource(lR, lC)
Next
Arr(lR) = Join(tmp, vbTab)
Next
.Write Join(Arr, vbCrLf)
.Close
End With
End With
ExitSub:
End Sub