vba coding for formula in cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
ActiveCell.FormulaR1C1 = "=R[-" & num1 & "]C-R[-" & num2 & "]C"
 
Thanks Tom. It looks so simple now.

Tom Ogilvy said:
ActiveCell.FormulaR1C1 = "=R[-" & num1 & "]C-R[-" & num2 & "]C"

--
Regards,
Tom Ogilvy

RDP1 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top