Hi,
I am trying to export excel data to text file in a particular format.
The Format for each ROW of Excel is like
IMAN_ROOT/bin/import_file -f=<Column A> -type=<Column B> -d=<Column C> -ref=<Column D> -vb -log=<Column E>
Every Row of the excel should export in text with this format.
I have been able to export all the cell values for each row but not in this format.
Should i use delimiter for each cell value for each row.
Any help would be highly appreciated.
this is my code for exporting
I am trying to export excel data to text file in a particular format.
The Format for each ROW of Excel is like
IMAN_ROOT/bin/import_file -f=<Column A> -type=<Column B> -d=<Column C> -ref=<Column D> -vb -log=<Column E>
Every Row of the excel should export in text with this format.
I have been able to export all the cell values for each row but not in this format.
Should i use delimiter for each cell value for each row.
Any help would be highly appreciated.
this is my code for exporting
Code:
Public Sub ExportToTextFile(FName As String, SelectionOnly As Boolean, AppendData As Boolean) Dim WholeLine As String Dim FNum As Integer Dim RowNdx As Long Dim ColNdx As Integer Dim StartRow As Long Dim EndRow As Long Dim StartCol As Integer Dim EndCol As Integer Dim CellValue As String Application.ScreenUpdating = False On Error GoTo EndMacro: FNum = FreeFile If SelectionOnly = True Then With Selection StartRow = .Cells(1).Row StartCol = .Cells(1).Column EndRow = .Cells(.Cells.Count).End(xlUp).Row EndCol = .Cells(.Cells.Count).Column End With Else With ActiveSheet.UsedRange StartRow = 4 StartCol = .Cells(1).Column EndRow = Cells(50000, "A").End(xlUp).Row EndCol = .Cells(.Cells.Count).Column End With End If If AppendData = True Then Open FName For Append Access Write As #FNum Else Open FName For Output Access Write As #FNum End If For RowNdx = StartRow To EndRow WholeLine = "" For ColNdx = StartCol To EndCol If Cells(RowNdx, ColNdx).Value = "" Then CellValue = Chr(34) & Chr(34) Else CellValue = Cells(RowNdx, ColNdx).Value End If WholeLine = WholeLine & CellValue & "," Next ColNdx WholeLine = Left(WholeLine, Len(WholeLine) - Len(",")) Print #FNum, WholeLine Next RowNdx EndMacro: On Error GoTo 0 Application.ScreenUpdating = True Close #FNum End Sub
Comment