Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Defining a Row Number

I am trying to automate a simple SUM calculation that is based upon a varying
cell range. For instance, Rows 3 to 6 inclusive have figures in that I want
to SUM in Row 7.

I currently have the following code but suspect that I have made a really
simple error with either the defining of CalcRow as Integer (String does not
work either), or the ActiveCell.Formula construction. Any ideas please?

Dim CalcRow As Integer

CalcRow = 3 - ActiveCell.Row

Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUM(R[CalcRow]C:R[-1]C)"

Many Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Defining a Row Number

Dim CalcRow As Long

CalcRow = 3 - ActiveCell.Row

Range("E2").FormulaR1C1 = "=SUM(R[" & CalcRow & "]C:R[-1]C)"


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Phil" wrote in message
...
I am trying to automate a simple SUM calculation that is based upon a
varying
cell range. For instance, Rows 3 to 6 inclusive have figures in that I
want
to SUM in Row 7.

I currently have the following code but suspect that I have made a really
simple error with either the defining of CalcRow as Integer (String does
not
work either), or the ActiveCell.Formula construction. Any ideas please?

Dim CalcRow As Integer

CalcRow = 3 - ActiveCell.Row

Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUM(R[CalcRow]C:R[-1]C)"

Many Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Defining a Row Number

Thanks a lot Bob. Much appreciated.

Phil

"Bob Phillips" wrote:

Dim CalcRow As Long

CalcRow = 3 - ActiveCell.Row

Range("E2").FormulaR1C1 = "=SUM(R[" & CalcRow & "]C:R[-1]C)"


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Phil" wrote in message
...
I am trying to automate a simple SUM calculation that is based upon a
varying
cell range. For instance, Rows 3 to 6 inclusive have figures in that I
want
to SUM in Row 7.

I currently have the following code but suspect that I have made a really
simple error with either the defining of CalcRow as Integer (String does
not
work either), or the ActiveCell.Formula construction. Any ideas please?

Dim CalcRow As Integer

CalcRow = 3 - ActiveCell.Row

Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUM(R[CalcRow]C:R[-1]C)"

Many 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
Defining cell with only through 1 - 32 Zee New Users to Excel 2 September 23rd 06 11:49 PM
Name Defining Chris Excel Discussion (Misc queries) 2 August 10th 06 03:06 PM
defining number range in textbox Ouka[_32_] Excel Programming 1 January 17th 06 08:56 AM
Defining Matt Excel Discussion (Misc queries) 1 July 26th 05 08:13 PM
Defining a number in a cell by text then subtracting it by the tex Crowraine Excel Worksheet Functions 1 December 16th 04 07:49 AM


All times are GMT +1. The time now is 07:21 AM.

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

About Us

"It's about Microsoft Excel"