Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sum using Variable

Hi-

The following code will sum the 14 rows above the row I am in. I want
to replace the -14 below with a variable (i). How do I code the below
to work with a variable?

ActiveCell.FormulaR1C1 = "=SUM(R[-14]C:R[-1]C)"

Thank You!

Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sum using Variable

ActiveCell.FormulaR1C1 = "=SUM(R[" & i & "]C:R[-1]C)"


"Fatz" wrote:

Hi-

The following code will sum the 14 rows above the row I am in. I want
to replace the -14 below with a variable (i). How do I code the below
to work with a variable?

ActiveCell.FormulaR1C1 = "=SUM(R[-14]C:R[-1]C)"

Thank You!

Chris

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Sum using Variable

Try

ActiveCell.FormulaR1C1 = "=SUM(R[" & i & "]C:R[-1]C)"

Remember, i must be a negative whole number in this example.

Hope this helps,

Hutch

"Fatz" wrote:

Hi-

The following code will sum the 14 rows above the row I am in. I want
to replace the -14 below with a variable (i). How do I code the below
to work with a variable?

ActiveCell.FormulaR1C1 = "=SUM(R[-14]C:R[-1]C)"

Thank You!

Chris

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Sum using Variable

Hi Chris,

To replace the negative constant (-14) with a varible, try:

Dim i As Long

i = -14

ActiveCell.FormulaR1C1 = "=SUM(R[" & i & "]C:R[-1]C)"


By the way, I believet that your formula
sums the 13 cells below the actice cell,
rather than the 14 cells above it.



---
Regards.
Norman

"Fatz" wrote in message
...
Hi-

The following code will sum the 14 rows above the row I am in. I want
to replace the -14 below with a variable (i). How do I code the below
to work with a variable?

ActiveCell.FormulaR1C1 = "=SUM(R[-14]C:R[-1]C)"

Thank You!

Chris


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sum using Variable

On May 5, 2:01*pm, "Norman Jones"
wrote:
Hi Chris,

To replace the negative constant (-14) with a varible, try:

* * Dim i As Long

* * i = -14

* * ActiveCell.FormulaR1C1 = "=SUM(R[" & i & "]C:R[-1]C)"

By the way, I believet that your formula
sums the 13 cells below the actice cell,
rather than the 14 cells above it.

---
Regards.
Norman

"Fatz" wrote in message

...



Hi-


The following code will sum the 14 rows above the row I am in. *I want
to replace the -14 below with a variable (i). *How do I code the below
to work with a variable?


ActiveCell.FormulaR1C1 = "=SUM(R[-14]C:R[-1]C)"


Thank You!


Chris- Hide quoted text -


- Show quoted text -


Thanks to everyone! It works great.....

Chris
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
Run-Time error '91': Object variable of With block variable not set jammin1911 Excel Programming 3 June 6th 06 06:36 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


All times are GMT +1. The time now is 06:11 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"