Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with cell reference



Hi,

I am trying to sum of few cell wherein i am not sure what would be the
maximum cell.

for example if i am using the below given formula it givs me the some of
cell one to cell four but i do not want the static result.
"=SUM(RC[1]:RC[4])"

will it possible if I assign a value to a variable:

like

a=20
and use the formula like this:

"=SUM(RC[1]:RC[a])"

- Harry

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Help with cell reference

Sub test()
Dim a As Long
Dim isum As Double
a = 20
isum = Application.WorksheetFunction.sum(Range( _
Cells(1, "A"), _
Cells(a, "A") _
))
MsgBox isum
End Sub

HTH
--
AP

"Harjinder Singh" a écrit dans le message de
...


Hi,

I am trying to sum of few cell wherein i am not sure what would be the
maximum cell.

for example if i am using the below given formula it givs me the some of
cell one to cell four but i do not want the static result.
"=SUM(RC[1]:RC[4])"

will it possible if I assign a value to a variable:

like

a=20
and use the formula like this:

"=SUM(RC[1]:RC[a])"

- Harry

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with cell reference


dim a as long
a=20
"=SUM(RC1:RC" & a & ")"
this will sum column 1 to column 20

Harjinder Singh Wrote:
Hi,

I am trying to sum of few cell wherein i am not sure what would be the
maximum cell.

for example if i am using the below given formula it givs me the som
of
cell one to cell four but i do not want the static result.
"=SUM(RC[1]:RC[4])"

will it possible if I assign a value to a variable:

like

a=20
and use the formula like this:

"=SUM(RC[1]:RC[a])"

- Harry

*** Sent via Developersdex http://www.developersdex.com **


--
kwiklearne
-----------------------------------------------------------------------
kwiklearner's Profile: http://www.excelforum.com/member.php...fo&userid=3190
View this thread: http://www.excelforum.com/showthread.php?threadid=52306

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Help with cell reference

the formula you show actually sums the 4 cells to the right of the cell
containing the formula.

You can supply a variable

a = 20
activecell.formulaR1C1 = "=Sum(RC[1]:RC[" & a & "])"

--
Regards,
Tom Ogilvy


"Harjinder Singh" wrote:



Hi,

I am trying to sum of few cell wherein i am not sure what would be the
maximum cell.

for example if i am using the below given formula it givs me the some of
cell one to cell four but i do not want the static result.
"=SUM(RC[1]:RC[4])"

will it possible if I assign a value to a variable:

like

a=20
and use the formula like this:

"=SUM(RC[1]:RC[a])"

- Harry

*** Sent via Developersdex http://www.developersdex.com ***

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
Changing sheet reference to cell reference TeeJay Excel Worksheet Functions 3 October 19th 07 11:50 AM
Formulas that reference cells that reference another cell Andrea Excel Discussion (Misc queries) 7 October 19th 06 08:14 AM
absolute cell reference A spreadsheet cell reference that does no help Excel Discussion (Misc queries) 1 January 18th 06 06:56 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


All times are GMT +1. The time now is 09:41 PM.

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"