View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Louise Louise is offline
external usenet poster
 
Posts: 217
Default Formula R1C1 in VBA - Strange Results (Dynamic)

Hi,

I have the following code in VBA to give me some variance % results.
Although the rows are always static the columns are not:

ActiveCell.FormulaR1C1 = "=SUM(R[-34]C-R[-17]C)/R[-17]C"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-32]C-R[-15]C)/R[-15]C"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-30]C-R[-13]C)/R[-13]C"

What I want this to do is to start in row 45, in the column i am in (worked
out prior to this in the macro) and put in a formula which basically in Excel
would read:

=SUM(I11-I28)/I28
then down one row
=SUM(I13-I30)/I30
then down one row
=SUM(I15-I32)/I32

This works, but only for the 1st and 3rd formulae, the second one is always
wrong by one row...

Am I doing something majorly wrong here?

Thanks,