Get Formula in Cell rather than Value

stephen antoine

Board Regular
Joined
Jun 4, 2008
Messages
128
Good evening,

I have a bit of code that uses variables to select a specific cell and then performs a calculation and dumps the value in the active cell...The problem is that I want the formula to be in the cell not the value...

The code I used is as follows:

Code:
ActiveCell.Formula = Cells(FinalRow + 2, CYSales).Value / ActiveCell.Offset(-5,0)

Where FinalRow and CYSales are my row and column variable...

My code works, but it dumps the value in the cell, I want the formula..

Can someone please help? :confused:
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

zzjasonzz

Well-known Member
Joined
Apr 23, 2006
Messages
649
ActiveCell.Formula = "=" & Cells(FinalRow + 2, CYSales).Value & "/" & ActiveCell.Offset(-5, 0)
 

stephen antoine

Board Regular
Joined
Jun 4, 2008
Messages
128
Thanks, that seemed to work partially, because now instead of a single value it's the value of the first cell divided by the value of the second cell, like the following:

=50/10

Where 50 is in cell C35 for instance and 10 is in cell E40

But I'm trying to get the cell reference to show up as well so the result would be something like this:

=C35/E40

Is that possible?
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
ActiveCell.Formula = "=" & Cells(FinalRow + 2, CYSales).Address(0,0) & "/" & ActiveCell.Offset(-5, 0).Address(0,0)
 

Watch MrExcel Video

Forum statistics

Threads
1,130,119
Messages
5,640,218
Members
417,131
Latest member
Seanr19871

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