Help with Offset formula?

jmthompson

Well-known Member
Joined
Mar 31, 2008
Messages
966
I am building a macro that includes the following lines:
Code:
Cells(lastRowWFO + 20, "E").Formula = "=(Activecell.Offset(-2,0) - Activecell.Offset(-2,-1))"
Cells(lastRowWFO + 20, "G").Formula = "=(Activecell.Offset(-2,0) - Activecell.Offset(-2,-1))"

I want to enter a formula in one cell which takes the value of the cell two rows above and subtracts the value in the cell two rows above and one column to the left. Since the location of these cells/rows will constantly change, I thought I'd use and offset function, but I'm doing something wrong.<SCRIPT language=JavaScript src="http://www.interq.or.jp/sun/puremis...[/XD][XH][/XH][/XR][/RANGE][/XH][/XR][/RANGE]
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Solved with the assistance of macro recorder...

Code:
Cells(lastRowWFO + 20, "E").Formula = "=R[-2]C-R[-2]C[-1]"
Cells(lastRowWFO + 20, "G").Formula = "=R[-2]C-R[-2]C[-1]"


note to self: get some sleep and stop overthinking things
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,448
Members
449,227
Latest member
Gina V

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