VBA Help creating a .txt file - Issue with 0's and decimals

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
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You would need to have all values set as text before outputting to the TXT file.
However, you might end up with an issue of quotation marks in the file.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top