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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

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
 

Forum statistics

Threads
1,140,944
Messages
5,703,312
Members
421,290
Latest member
james90

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
Top