View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default vba coding for formula in cell

ActiveCell.FormulaR1C1 = "=R[-" & num1 & "]C-R[-" & num2 & "]C"

--
Regards,
Tom Ogilvy

"RDP1" wrote in message
...
I am trying to use vba code to enter a formula similar to the one below.

ActiveCell.FormulaR1C1 = "=R[-31]C-R[-32]C"

The differences are that the [-31] and [-32] are dependent upon the number
of rows in a section of the spreadsheet. They can be calculated by the
following:
Num1 = Range("Top_adj:Bottom_adj").Rows.Count + 3
and
Num 2= Range("Top_adj:Bottom_adj").Rows.Count + 2

What is the code? Thanks.