Hello Experts,
I am trying to do some calculations on data in excel sheet and then export them in a standardized form of a text file.
to do this I used the file system object (adding the Microsoft script runtime reference from vb tools menu) the following code works fine with me..except that I cannot get the output right or left justified
this exports the data in the following form:
I need to have the first set always left justified, while the 2nd set of numbers to be always right justified, beginning from column 30 in the text file up to column 37....in other words...this is my desired output:
the second thing I may have a problem with is the number of rows is not fixed...so I want the loop to include all the rows, should I use something line for i = 1 to endxlUp? or what is the best function for that?
your help is much appreciated
thanks and regards.
I am trying to do some calculations on data in excel sheet and then export them in a standardized form of a text file.
to do this I used the file system object (adding the Microsoft script runtime reference from vb tools menu) the following code works fine with me..except that I cannot get the output right or left justified
Code:
Sub exporttext()
Dim i As Integer
Dim fso As FileSystemObject
Dim hope As TextStream
Set fso = New FileSystemObject
Set hope = fso.CreateTextFile("D:\hope.txt", True)
With hope
For i = 1 To 10
.WriteLine (Cells(i, 1) & Space(4) & Cells(i, 2))
Next i
.Close
End With
Dim x
x = Shell("notepad.exe d:\hope.txt", 1)
End Sub
Code:
123 345
3245 325
43 235
43 3245
2325 3190
1516.4 4051
1636.6 4912
1756.8 5773
1877 6634
1997.2 7495
Code:
123 345
3245 325
43 235
43 3245
2325 3190
1516.4 4051
1636.6 4912
1756.8 5773
1877 6634
1997.2 7495
your help is much appreciated
thanks and regards.