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
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top