putting an equation in a column?

xtscars

New Member
Joined
Apr 11, 2011
Messages
17
So far I have learned how to copy and paste my final column in VB. Now, how do I tell it to create an equation in finalcolumn+1? The equation is simply the difference in the prior two columns.

a b c d
1 x y z =z-y
2 x y z =z-y
3 x y z =z-y

how do I code that last column d to put that equation in?

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
thank you! but instead of hard coding that D range, how can I get it to always be finalcolumn+1? Can I just put range(finalcolumn+1)?
 
Upvote 0
Try

range(Cells(1,finalcolumn+1),cells(100,finalcolumn+1)).FormulaR1C1="=RC[-1]-RC[-2]"
 
Upvote 0
thank you for the help! that worked great. Now, my only problem is that there are some cells that need to be deleted because there aren't any cells to the left of it for the equation to calculate. Do you have any ideas for how I can use variables to delete those cells? If this doesn't make sense, let me know and I'll try to be more specific. Thanks!
 
Upvote 0
would you be willing to give me a little more guidance on how to use that code? I would appreciate it. Thanks again.
 
Upvote 0
The code would be like this

Code:
Range(Cells(1, lastcol), Cells(100, lastcol)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

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