ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Formula Instead of Value (https://www.excelbanter.com/excel-programming/363754-copy-formula-instead-value.html)

Emily[_3_]

Copy Formula Instead of Value
 
Hi,

I've tried both of the following in my VB macro:

Sheet2.Cells(i, 17).Value = Sheet2.Cells(2, 17).Value

and

Sheet2.Cells(i, 17).Formula = Sheet2.Cells(2, 17).Formula

Either way, it sets the value to the value that appears in the cell.
I'll need to copy the formula over. Any advice on what syntax I shall
use? Many thanks!

-Emily


Jim Thomlinson

Copy Formula Instead of Value
 
This worked for me...

Sub test()
Sheet1.Range("A2").FormulaR1C1 = Sheet1.Range("A1").FormulaR1C1
End Sub
--
HTH...

Jim Thomlinson


"Emily" wrote:

Hi,

I've tried both of the following in my VB macro:

Sheet2.Cells(i, 17).Value = Sheet2.Cells(2, 17).Value

and

Sheet2.Cells(i, 17).Formula = Sheet2.Cells(2, 17).Formula

Either way, it sets the value to the value that appears in the cell.
I'll need to copy the formula over. Any advice on what syntax I shall
use? Many thanks!

-Emily



Emily[_3_]

Copy Formula Instead of Value
 
Hi Jim,

Could you tell me what "FormulaR1C1" is? Why don't you use "Formula"
instead?

Also What is "Range("A2")"? Is it equivalent to "Cells(2, 1)"?

One more question: If I want to copy a formula to column K from row 4
to 50, what's the most efficient way to do it?

Thanks!

-Emily



All times are GMT +1. The time now is 02:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com