Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I am using a script to convert an Excel sheet to a txt file and it works ok. But some fields need to be aligned to the right in stead of default left. Can anyone tell me how to do this? Not all values but only some of the fields in the excel sheets The code used: Public Sub FixedFieldTextFile() Const DELIMITER As String = "" Const PAD As String = " " Dim vFieldArray As Variant Dim myRecord As Range Dim nFileNum As Long Dim i As Long Dim sOut As String vFieldArray = Array(4, 8, 4, 4, 15, 4, 13, 8, 8, 25, 40, 123) nFileNum = FreeFile Open "c:\NOB50850.txt" For Output As #nFileNum For Each myRecord In Range("A1:A" & _ Range("A" & Rows.Count).End(xlUp).Row) With myRecord For i = 0 To UBound(vFieldArray) sOut = sOut & DELIMITER & Left(.Offset(0, i).Text & _ String(vFieldArray(i), PAD), vFieldArray(i)) Next i POLine = POLine + 1 Print #nFileNum, Mid(sOut, Len(DELIMITER) + 1) sOut = Empty End With Next myRecord Close #nFileNum End Sub The excel sheet: Left Left Right Left Right 5010 12345678 1 Custpart1 0 10 Left Left Left 01/07/07 19/06/07 G16SA3C |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
convert email address file in Excel 2000 to Word file with commas | Excel Discussion (Misc queries) | |||
How do convert a quattro pro 10 file to an excel 2003 file? | Excel Discussion (Misc queries) | |||
excel 2002 -how can you convert a file to a pdf read only file? | Excel Discussion (Misc queries) | |||
How do I convert an excel file into a comma separated values file | Excel Discussion (Misc queries) | |||
How do I convert excel file into ASCII text file with alignment? | Excel Discussion (Misc queries) |