![]() |
vba coding for formula in cell
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. |
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. |
vba coding for formula in cell
Thanks Tom. It looks so simple now.
"Tom Ogilvy" wrote: 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. |
All times are GMT +1. The time now is 01:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com