Hi, I am using the below code to Generate a text File in pipe Delimited format.
But now I have to have a Pipe after the last line.
Like below (As an example)
ASD|DEPFR|2451|ASDFERTT|
What to change in the code to achieve the expected result.
Any suggestion?
Thanks and Best regards.
VBA Code:
Sub ExportTxt()
Dim UsedRows As Long
Dim UsedColumns As Long
Dim R As Long, C As Long
'// Define a suitable file name
Open "E:\Folder\" & "TD.txt" For Output As #1
With ActiveSheet
UsedRows = .UsedRange.Rows.Count
UsedColumns = .UsedRange.Columns.Count
For R = 2 To UsedRows
For C = 1 To UsedColumns
Select Case C
Case 2 ' Numeric Column with 2 decimals
Print #1, Format(.Cells(R, C), "#.00"); "|";
Case UsedColumns ' Last Column end of line
Print #1, .Cells(R, C)
Case Else
Print #1, .Cells(R, C); "|";
End Select
Next C
Next R
End With
Close #1
End Sub
But now I have to have a Pipe after the last line.
Like below (As an example)
ASD|DEPFR|2451|ASDFERTT|
What to change in the code to achieve the expected result.
Any suggestion?
Thanks and Best regards.