bachuwar.rajenderprasad
New Member
Dear Friends,
I have the below code to create a textfile on my desktop with a used range.
When I ran the below macro for the first time used range was 805, then it was 600. But still the below code is using the range as 805 only.
Please suggest.
Sub Create_File()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
Dim count_val As Long
count_val = Worksheets("Payments").UsedRange.Rows.Count
sFile = "C:Usersrajender_prasadDesktopTextfile.sql"
'MsgBox sText
iFileNum = FreeFile
Open sFile For Output As iFileNum
For i = 4 To count_val
sText = Worksheets("Payments").Range("N" & i).Value & ";"
Print #iFileNum, sText
'Print #iFileNum, "More text on next line"
'Print #iFileNum, "Etc."
Next
Close #iFileNum
MsgBox "file is created " & sFile
End Sub
Regards,
Prasad
I have the below code to create a textfile on my desktop with a used range.
When I ran the below macro for the first time used range was 805, then it was 600. But still the below code is using the range as 805 only.
Please suggest.
Sub Create_File()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
Dim count_val As Long
count_val = Worksheets("Payments").UsedRange.Rows.Count
sFile = "C:Usersrajender_prasadDesktopTextfile.sql"
'MsgBox sText
iFileNum = FreeFile
Open sFile For Output As iFileNum
For i = 4 To count_val
sText = Worksheets("Payments").Range("N" & i).Value & ";"
Print #iFileNum, sText
'Print #iFileNum, "More text on next line"
'Print #iFileNum, "Etc."
Next
Close #iFileNum
MsgBox "file is created " & sFile
End Sub
Regards,
Prasad