Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Summing rows using formulas with variables

Long story short- I have a range, columns are years, rows are
numerical data. I want to be able to enter a start year and an end
year into two different cells (entirely separate from the range) that
feed into a formula that then sums whichever type of data a row
happens to be between those two years. By adding a row at the bottom
of the range that contains A, B, C and so on (and they are in the A,
B, C, etc columns; was there a better way to return the column letter?
I tried COLUMN but only got numerical values, not the letters.) I was
able to return "B", as the first part of a cell reference. The first
data I am trying to sum is in Row 13, so I attempting to sum from B13
to B17. I got the "B" by doing HLOOKUP(B2,B12:AE20,9), but when I try
to add the 13 to make the formula reference cell B13, I get an error
message. How do I make the formula look at cell B13? I am weak on
macros, and know nothing about VBA. Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default Summing rows using formulas with variables

On Oct 24, 10:53*am, Gateway204 wrote:
Long story short- I have a range, columns are years, rows are
numerical data. I want to be able to enter a start year and an end
year into two different cells (entirely separate from the range) that
feed into a formula that then sums whichever type of data a row
happens to be between those two years. By adding a row at the bottom
of the range that contains A, B, C and so on (and they are in the A,
B, C, etc columns; was there a better way to return the column letter?
I tried COLUMN but only got numerical values, not the letters.) I was
able to return "B", as the first part of a cell reference. The first
data I am trying to sum is in Row 13, so I attempting to sum from B13
to B17. I got the "B" by doing HLOOKUP(B2,B12:AE20,9), but when I try
to add the 13 to make the formula reference cell B13, I get an error
message. How do I make the formula look at cell B13? I am weak on
macros, and know nothing about VBA. Thanks in advance.


how about just using a SUMPRODUCT formula
=sumproduct((a2:a22=b1)*(a2:a22<b2)*b2:b22)
modify to suit and do NOT use entire columns.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,045
Default Summing rows using formulas with variables

On Mon, 24 Oct 2011 08:53:44 -0700 (PDT), Gateway204 wrote:

Long story short- I have a range, columns are years, rows are
numerical data. I want to be able to enter a start year and an end
year into two different cells (entirely separate from the range) that
feed into a formula that then sums whichever type of data a row
happens to be between those two years. By adding a row at the bottom
of the range that contains A, B, C and so on (and they are in the A,
B, C, etc columns; was there a better way to return the column letter?
I tried COLUMN but only got numerical values, not the letters.) I was
able to return "B", as the first part of a cell reference. The first
data I am trying to sum is in Row 13, so I attempting to sum from B13
to B17. I got the "B" by doing HLOOKUP(B2,B12:AE20,9), but when I try
to add the 13 to make the formula reference cell B13, I get an error
message. How do I make the formula look at cell B13? I am weak on
macros, and know nothing about VBA. Thanks in advance.


I'm not sure I understand your setup of data, and I do not understand why you want to return the letters relating to the columns which contain the years.

If your years are in columns, then possibly your setup is like:

B1: Year 1 (e.g. 2000)
C1: Year 2 (2001)
D1: Year 3 (2002)
....

And if your data is in rows starting with row 2 and assume a label in A2 with actual data in B2 rightward.

If that is the case, you can sum that part of the row that starts at a StartYear column and ends and an EndYear column with the following formula:

This formula must be **array-entered**:

=SUM(OFFSET($A$1,RowToSum,MATCH(
StartYear,$1:$1,0)-1,1,EndYear-StartYear+1))

StartYear, EndYear and RowToSum are all in individual cells someplace on your worksheet.
RowToSum is the first row of data, Not the row number in the worksheet, but you could equally well MATCH a label similar to the way we used MATCH to determine the StartYear.
If you need to specify multiple rows, that can be done by adjusting the [height] parameter in the OFFSET function similarly to the adjustment we did for the [width] parameter.

----------------------------------------

To **array-enter** a formula, after entering
the formula into the cell or formula bar, hold down
<ctrl<shift while hitting <enter. If you did this
correctly, Excel will place braces {...} around the formula.

If your layout is different, you will need to be more explicit.
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
Summing 2 columns based on variables Steve Excel Worksheet Functions 3 April 7th 10 08:56 PM
Summing up various Worksheets to one Summary sheet using variables Terri[_3_] Excel Discussion (Misc queries) 1 October 2nd 09 10:33 PM
Summing graphs without differnt independent variables Sebastian Stormbo Charts and Charting in Excel 5 July 18th 08 05:12 PM
Variables in formulas build Excel Worksheet Functions 9 October 11th 07 12:35 PM
summing cells with variables jeff Excel Discussion (Misc queries) 5 March 3rd 05 07:25 PM


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