P
pikapika13
I currently have the following code. It basically appends a chunk of
data at the end of a .txt file. However, the way its formatting is not
what I want. Currently, it takes each cell in Range(A1:J?) and makes
it's own row in the .txt file. I want a tab delimited file that
maintains the column-like format A:J.
Example:
What I have and don't want in the .txt file:
Data1
Data2
Data3
etc.
What I need:
Data1 Data2 Data3 ....Data8
Data9 Data10 ........Data16 etc.
Sub XfertoNotepad()
Dim FileNum As Integer
Sheets("SQL").Select
Range("A2").Select
With ActiveSheet
Set Lend = .Cells(.Rows.Count, "J").End(xlUp)
End With
FileNum = FreeFile
Open "C:\4x\" & docsol For Append As #FileNum
Print #FileNum, [a2]
For Each cl In Range("A3:" & Lend)
Print #FileNum, myStr
myStr = "": myStr = myStr & cl
Next
'appends the input to an existing file write to the textfile
Print #FileNum, myStr
Close #FileNum ' close the file
End Sub
data at the end of a .txt file. However, the way its formatting is not
what I want. Currently, it takes each cell in Range(A1:J?) and makes
it's own row in the .txt file. I want a tab delimited file that
maintains the column-like format A:J.
Example:
What I have and don't want in the .txt file:
Data1
Data2
Data3
etc.
What I need:
Data1 Data2 Data3 ....Data8
Data9 Data10 ........Data16 etc.
Sub XfertoNotepad()
Dim FileNum As Integer
Sheets("SQL").Select
Range("A2").Select
With ActiveSheet
Set Lend = .Cells(.Rows.Count, "J").End(xlUp)
End With
FileNum = FreeFile
Open "C:\4x\" & docsol For Append As #FileNum
Print #FileNum, [a2]
For Each cl In Range("A3:" & Lend)
Print #FileNum, myStr
myStr = "": myStr = myStr & cl
Next
'appends the input to an existing file write to the textfile
Print #FileNum, myStr
Close #FileNum ' close the file
End Sub