PDA

View Full Version : Trouble with pasting a formula



Hoopsah
11-18-2009, 06:36 AM
Hi

I ran a macro to copy a formula into a cell and copy it down a range but I cannot get it to work correctly.

The formula should read - =$A$1-D3 and be copied down the column.

When I did a "Record Macro" it showed it as:
ActiveCell.FormulaR1C1 = "=R[-2]C-RC[3]"

but even if I leave it like that it ends up filling the cell with =R[-2]C-RC[3]

Can anyone tell me of a macro that will insert the formula =$A$1-D3 and copy it down the column

Thanks for any help


Hoopsah

p45cal
11-18-2009, 06:58 AM
use
Range("F3:F33").Formula = "=$A$1-D3"

btw, are column headers showing as 1,2,3,4 etc. on the sheet, or as A,B,C,etc.?

Hoopsah
11-18-2009, 07:09 AM
Magic!

That works - My columns are showing as A B C

Cheers

Hoopsah

mdmackillop
11-18-2009, 08:45 AM
Both of these should work

Selection.FormulaR1C1 = "=R[-2]C-RC[3]"
Range("F3:F33").FormulaR1C1 = "=R[-2]C-RC[3]"