jakerogers77
New Member
- Joined
- Nov 26, 2013
- Messages
- 8
Hello,
I recently created a macro to create a pipe delimited file from a large spreadsheet. The system that processes the .txt file cannot handle 0's in any cells, but it can handle it if there are decimals (i.e. 0.0). Changing the format of the amounts in the spreadsheet to have decimals doesn't fix the issue as it still prints to the text file as just 0. Does anyone have any suggestions on how to circumvent this? Would greatly appreciate any help!
---------------
Sub ExportPipe2()
Dim UsedRows As Long
Dim UsedColumns As Long
Dim i As Long, j As Long
Dim StartTime As Double
Dim MinutesElapsed As String
'Open txt file
Open "C:\pipedexport.csv" For Output As #1
'Print to text file
With ActiveSheet
UsedRows = Selection.Rows.Count
UsedColumns = Selection.Columns.Count
For i = 1 To UsedRows
For j = 1 To UsedColumns - 1
Print #1 , .Cells(i, j); "|";
Next j
Print #1 , .Cells(i, UsedColumns)
Next i
End With
Close #1
'Notify
MsgBox "Done"
End Sub
---------------
Thank you.
Jake
I recently created a macro to create a pipe delimited file from a large spreadsheet. The system that processes the .txt file cannot handle 0's in any cells, but it can handle it if there are decimals (i.e. 0.0). Changing the format of the amounts in the spreadsheet to have decimals doesn't fix the issue as it still prints to the text file as just 0. Does anyone have any suggestions on how to circumvent this? Would greatly appreciate any help!
---------------
Sub ExportPipe2()
Dim UsedRows As Long
Dim UsedColumns As Long
Dim i As Long, j As Long
Dim StartTime As Double
Dim MinutesElapsed As String
'Open txt file
Open "C:\pipedexport.csv" For Output As #1
'Print to text file
With ActiveSheet
UsedRows = Selection.Rows.Count
UsedColumns = Selection.Columns.Count
For i = 1 To UsedRows
For j = 1 To UsedColumns - 1
Print #1 , .Cells(i, j); "|";
Next j
Print #1 , .Cells(i, UsedColumns)
Next i
End With
Close #1
'Notify
MsgBox "Done"
End Sub
---------------
Thank you.
Jake