Hi There,
I am not getting any data in generated text file using macros.
Anyone please help .
Here is the Code
Sub SaveAsPipeDelimited()
Dim vFileName As Variant
Dim rngLastCell As Range
Dim lLastRow As Long
Dim nLastCol As Integer
Dim lCurrRow As Long
Dim nCurrCol As Integer
Dim sRowString As String
vFileName = Application.GetSaveAsFilename(filefilter:= _
"Text Files (*.txt), .txt")
If vFileName <> False Then
Open vFileName For Output As #1
Set rngLastCell = ActiveSheet.Range("Table1"). _
SpecialCells(xlLastCell)
lLastRow = rngLastCell.End(xlUp).Row
nLastCol = rngLastCell.Column
For lCurrRow = 2 To lLastRow
sRowString = ActiveSheet.Cells(lCurrRow, 1).Formula
For nCurrCol = 2 To nLastCol
sRowString = sRowString & "|" & ActiveSheet _
.Cells(lCurrRow, nCurrCol).Formula
Next nCurrCol
If Len(sRowString) = nLastCol - 1 Then
'/ print blank line only
Print #1,
Else
Print #1, sRowString
End If
Next lCurrRow
Close #1
End If
End Sub
Bookmarks