Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.




  #2   Report Post  
Posted to microsoft.public.excel.programming
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.






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color Coding cell based on date (over a large range) Randy1360 New Users to Excel 3 January 29th 10 09:56 PM
converting question; function, formula, or coding? gtrask Excel Worksheet Functions 4 July 8th 08 12:25 AM
hard coding a cell darrelly Excel Discussion (Misc queries) 2 October 7th 05 11:24 PM
Formula Color Coding Andrew Excel Discussion (Misc queries) 5 March 25th 05 08:41 PM
VB coding to go to last cell at end of any given row? StargateFan[_3_] Excel Programming 5 January 31st 05 06:01 AM


All times are GMT +1. The time now is 02:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"