could u help me write this table retaining table spacing and
formatting,
table in excel file is as follows:
col b col c col d
Black-Scholes Directly in a Excel Sheet
Stock price S 61
Strike price X 65
Years to maturity T 0.25
Risk-free rate r 0.08
Volatility v 0.3
d1 -0.215
d2 -0.365
European call value 2.527
European put value 5.240
------------------------------=AD------------------------------=AD-------
here is code to write this table to a txt file:
code ro read as follows:
a range name of the excel table is defined as "worksheet_to_text"
------------------------------=AD=AD-----------------------------=AD-=AD---=
-------------------------=AD--=AD--------------------
Sub writetabletotxtfile()
Dim ExpRng As Range
Dim ff As Integer
Set ExpRng =3D Range("worksheet_to_text")
Firstcol =3D ExpRng.Columns(1).Column
LastCol =3D Firstcol + ExpRng.Columns.Count
FirstRow =3D ExpRng.Rows(1).Row
LastRow =3D FirstRow + ExpRng.Rows.Count
ff =3D FreeFile()
Open "C:\Documents and Settings\XYZ\Desktop\tabletote=AD=ADxtfile.txt"
For
Output As ff
Print #ff, ExpRng.AddressLocal()
Print #ff, ExpRng.AddressLocal(RowAbsolut=AD=ADe:=3DFalse,
columnabsolute:=3DFalse)
For r =3D FirstRow To LastRow
For c =3D Firstcol To LastCol
Print #ff, Cells(r, c);
Next c
Print #ff, 'blank line
Next r
Close ff
End Sub
------------------------------=AD=AD-----------------------------=AD-=AD---=
-----------------
Here is the result txt file. see how recreated table line by line but
still unable to get spacing right. plz help
$B$2:$E$18
B2:E18
Black-Scholes Directly in a Excel Sheet
Stock priceS 61
Strike priceX 65
Years to maturityT 0.25
Risk-free rater 0.08
Volatilityv 0.3
d1-0.215089371482172
d2-0.365089371482172
European call value 2.52698589175614
European put value 5.23989965669523
------------------------------=AD------------------------------=AD---------=
---------------------=AD-----
could u help me write this table retaining table spacing and
formatting.=20
thanks folks, deano
Bookmarks