Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm not very good with code, so I found the code below somewhere off the net that exports a worksheet to a pipe delimited .txt file. Everything works as expected except for exporting currency. It leaves off the zeros and the zeros are needed. Example: $45.00 to | 45. | or $45.80 to | 45.8 | Is it possible to export with the zeros included? Like: $45.00 to | 45.00 | or $45.80 to | 45.80 | Thanks for any help, Barb *****Pipe Delimited Macro***** Sub PipeDelimited() ' Exports to PipeDel.txt file Dim SrcRg As Range Dim CurrRow As Range Dim CurrCell As Range Dim CurrTextStr As String Dim ListSep As String Dim DataTextStr As String ListSep = "|" Set SrcRg = ActiveSheet.UsedRange Open "C:\windows\desktop\PipeDel.txt" For Output As #1 For Each CurrRow In SrcRg.Rows CurrTextStr = "" For Each CurrCell In CurrRow.Cells CurrTextStr = CurrTextStr & CurrCell.Value & ListSep Next While Right(CurrTextStr, 1) = ListSep CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1) Wend 'Added next line to put | at end of each line CurrTextStr = CurrTextStr & ListSep Print #1, CurrTextStr Next Close #1 End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
one way:
Change CurrTextStr = CurrTextStr & CurrCell.Value & ListSep to CurrTextStr = CurrTextStr & Format(CurrCell.Value,"00.00") _ & ListSep In article , "Barb" wrote: Hi, I'm not very good with code, so I found the code below somewhere off the net that exports a worksheet to a pipe delimited .txt file. Everything works as expected except for exporting currency. It leaves off the zeros and the zeros are needed. Example: $45.00 to | 45. | or $45.80 to | 45.8 | Is it possible to export with the zeros included? Like: $45.00 to | 45.00 | or $45.80 to | 45.80 | Thanks for any help, Barb *****Pipe Delimited Macro***** Sub PipeDelimited() ' Exports to PipeDel.txt file Dim SrcRg As Range Dim CurrRow As Range Dim CurrCell As Range Dim CurrTextStr As String Dim ListSep As String Dim DataTextStr As String ListSep = "|" Set SrcRg = ActiveSheet.UsedRange Open "C:\windows\desktop\PipeDel.txt" For Output As #1 For Each CurrRow In SrcRg.Rows CurrTextStr = "" For Each CurrCell In CurrRow.Cells CurrTextStr = CurrTextStr & CurrCell.Value & ListSep Next While Right(CurrTextStr, 1) = ListSep CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1) Wend 'Added next line to put | at end of each line CurrTextStr = CurrTextStr & ListSep Print #1, CurrTextStr Next Close #1 End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perfect!! That was exactly what I was looking for. Thank you kindly
J.E. for your help and keeping it simple for me. :) Barb "J.E. McGimpsey" wrote in message ... | one way: | | Change | | CurrTextStr = CurrTextStr & CurrCell.Value & ListSep | | to | | CurrTextStr = CurrTextStr & Format(CurrCell.Value,"00.00") _ | & ListSep | | | In article , | "Barb" wrote: | | Hi, | | I'm not very good with code, so I found the code below somewhere off | the net that exports a worksheet to a pipe delimited .txt file. | Everything works as expected except for exporting currency. It leaves | off the zeros and the zeros are needed. | | Example: $45.00 to | 45. | or $45.80 to | 45.8 | | | Is it possible to export with the zeros included? | Like: $45.00 to | 45.00 | or $45.80 to | 45.80 | | | Thanks for any help, | Barb | | *****Pipe Delimited Macro***** | | Sub PipeDelimited() | | ' Exports to PipeDel.txt file | | Dim SrcRg As Range | | Dim CurrRow As Range | | Dim CurrCell As Range | | Dim CurrTextStr As String | | Dim ListSep As String | | Dim DataTextStr As String | | ListSep = "|" | | Set SrcRg = ActiveSheet.UsedRange | | Open "C:\windows\desktop\PipeDel.txt" For Output As #1 | | For Each CurrRow In SrcRg.Rows | | CurrTextStr = "" | | For Each CurrCell In CurrRow.Cells | | CurrTextStr = CurrTextStr & CurrCell.Value & ListSep | | Next | | While Right(CurrTextStr, 1) = ListSep | | CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1) | | Wend | | 'Added next line to put | at end of each line | | CurrTextStr = CurrTextStr & ListSep | | Print #1, CurrTextStr | | Next | | Close #1 | | End Sub | | |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
refer some letter from one cell(pipe/mech or mech/pipe (reqd: pi) | Excel Worksheet Functions | |||
Pipe-Delimited CSv File | Excel Discussion (Misc queries) | |||
How can I convert tab delimited files to pipe delimited? | Excel Discussion (Misc queries) | |||
Save CSV file as Pipe delimited text file | Excel Discussion (Misc queries) | |||
Import Pipe Delimited File, Parse out certian Fields, create new f | New Users to Excel |