I tried the following code to copy cells to text file so that the macro searches for the cells till the last cell that has data and exports them to text file, this is the code I used:
Sub prn()
last = Cells(Rows.Count, 1).End(xlUp)
Dim txt As String
txt = "d:/textfile.txt"
Open "d:/textfile.txt" For Output As #1
Dim i As Integer
For i = 1 To last
A = Cells(i, 1) & " " & Cells(i, 2)
Print #1, A
Next i
Close #1
Dim x
x = Shell("notepad.exe d:\textfile.txt", 1)
'
End Sub
the code works fine till a specific number of rows, I think till 10 rows, if more rows are introduced it begins exporting only the first 3 or 4 rows and ignores the rest, in a reverse way, i.e if I intoduce 11 rows, 9 rows are exported to text, if 12 rows are written then 8 rows are exported to text and so on.
can some one tell me please what is wrong with this code?
Bookmarks