Don't know where I'm going wrong!

allenD

New Member
Joined
Sep 9, 2006
Messages
5
Need HELP! I don't know where I'm going wrong here. Will someone please point out my errors and show me the correct way to write this code:

Sub SP500_Test_Model()

Dim curPrice
Dim lookBackPrice
Dim percentChg

Workbooks("sp500.xls").Sheets("prices").Range("e3").Value =

curPrice
Workbooks("sp500.xls").Sheets("prices").Range("e20").Value =

lookBackPrice
percentChg = "=abs((curPrice-lookBackPrice)/(lookBackPrice))"

Range("e3").Select
Selection.percentChg
Range("e4").Select
Selection.AutoFill Destination:=Range("e4:e5000"),

Type:=xlFillDefault

End Sub
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi,

this does compile correctly, but doesn't make much sense to me
Code:
Sub SP500_Test_Model()

Dim curPrice
Dim lookBackPrice
Dim percentChg

curPrice = Workbooks("sp500.xls").Sheets("prices").Range("e3").Value
lookBackPrice = Workbooks("sp500.xls").Sheets("prices").Range("e20").Value
percentChg = Abs((curPrice - lookBackPrice) / (lookBackPrice))

Range("e3") = percentChg
Range("e4").AutoFill Destination:=Range("e4:e5000"), Type:=xlFillDefault

End Sub
what are you trying to do: please tell us in plain english and provide an example

kind regards,
Erik
 

Watch MrExcel Video

Forum statistics

Threads
1,113,920
Messages
5,545,029
Members
410,647
Latest member
bernardazar
Top