Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default sum a column with a variable

i want to sum up a column say from a1 to a12 which i s not too difficult. the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12 depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do that.
could the number 1 in a1 be a variable somehow? abdul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 222
Default sum a column with a variable

Answered in your other thread:
http://www.microsoft.com/communities...r=US&sloc=&p=1
--
"Actually, I *am* a rocket scientist." -- JB

Your feedback is appreciated, click YES if this post helped you.


"abdul" wrote:

i want to sum up a column say from a1 to a12 which i s not too difficult. the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12 depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do that.
could the number 1 in a1 be a variable somehow? abdul

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default sum a column with a variable

Use INDIRECT():

We will put the limits in cells B1 and B2. In B1 enter:
3
and in B2 enter:
7

In B3 we can enter:

=SUM(INDIRECT("A" & B1 & ":A" & B2))
which basically pulls the limits out of B1 and B2, making it equivalent to:

=SUM(A3:A7)

So you can change the limits to the sum by changed in values in B1 & B2.
--
Gary''s Student - gsnu200832


"abdul" wrote:

i want to sum up a column say from a1 to a12 which i s not too difficult. the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12 depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do that.
could the number 1 in a1 be a variable somehow? abdul

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default sum a column with a variable

Type a number from 1 to 12 in cell B1
In any other cell use =SUM(INDIRECT("A"&B1&":A12"))
If B1 holds the number 4 for example, then this formula is equivalent to
=SUM(A4:A12)
Is this what was required?
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"abdul" wrote in message
...
i want to sum up a column say from a1 to a12 which i s not too difficult.
the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12
depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do
that.
could the number 1 in a1 be a variable somehow? abdul



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default sum a column with a variable

whatRow = InputBox("What row to start summing")
With Worksheets("Sheet1")
If IsEmpty(.Cells(.Rows.Count, 1)) Then
With .Cells(.Rows.Count, 1).End(xlUp)
.Offset(2, 0).Formula = "=Sum($A$" & whatRow & ":" & _
.Address & ")"
End With
End If
End With

"abdul" wrote:

i want to sum up a column say from a1 to a12 which i s not too difficult. the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12 depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do that.
could the number 1 in a1 be a variable somehow? abdul



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default sum a column with a variable

whatRow = InputBox("What row to start summing")
With Worksheets("Sheet1")
If IsEmpty(.Cells(.Rows.Count, 1)) Then
With .Cells(.Rows.Count, 1).End(xlUp)
.Offset(2, 0).Formula = "=Sum($A$" & whatRow & ":" & _
.Address & ")"
End With
End If
End With

"abdul" wrote:

i want to sum up a column say from a1 to a12 which i s not too difficult. the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12 depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do that.
could the number 1 in a1 be a variable somehow? abdul

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default sum a column with a variable

answered in your other posting
=SUM(INDEX(A:A,C1):INDEX(A:A,C2))
with C1 holding start row and C2 holding end row
--
Regards
Roger Govier

"abdul" wrote in message
...
i want to sum up a column say from a1 to a12 which i s not too difficult.
the
problem is that i sometimes want to sum up a3 to a12 or a5 to a12
depending
on what number has been entered. is there a way to make the function
sum(a1:a12) add different number of rows. is there any other way to do
that.
could the number 1 in a1 be a variable somehow? abdul


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
variable column Libby Excel Worksheet Functions 1 January 28th 08 06:32 PM
Sum by variable column gr Excel Discussion (Misc queries) 3 September 23rd 06 08:46 PM
copy a range with known start column to variable end column Matilda Excel Programming 2 August 2nd 06 04:55 PM
Offset from a variable column to a fixed column Kurt Barr Excel Programming 2 June 27th 06 05:45 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM


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