
Originally Posted by
Andy Pope
It would help if you posted the code you have and explain why it does not quite solve your problem.
I guess it would, eh? Sorry about that.
The code below I had found while searching this forum, but I am unsure of how to manipulate it to accomplish what I need:
Sub CreateTextFile()
Sheets("ASCII01").Select
Dim FB As Integer 'File Buffer Number
Dim FileName As String
Dim FilePath As String
Dim LastRow As Long
Dim MyFile As String
Dim R As Long
Dim Rng As Range
Dim StartRow As Long
StartRow = 1
With ActiveSheet.UsedRange
LastRow = .Rows.Count + .Row - 1
End With
FB = FreeFile
FileName = "DHPT01.txt"
FilePath = "C:\"
MyFile = FilePath & "\" & FileName
Open MyFile For Output As #FB
For R = StartRow To LastRow
Set Rng = Range(Cells(R, "A"), Cells(R, "G"))
Print #FB,
Print #FB,
Print #FB,
Print #FB,
Print #FB,
Print #FB,
Print #FB, 'Add a blank line
Next R
Close #FB
End Sub
The code/macro will be attached to a button on the main sheet, which is why I use the Sheets("ASCII01").select to switch to the sheet I want to write.
I just need to modify the code to scan the worksheet and write all the applicable rows, comma delimited.
Please edit as necessary, and I do appreciate your work on the matter.
Cheers, S/T
Bookmarks