handling range of data from the middle with sumproduct

baseball

Board Regular
I have a table of yearly statistics for baseball teams from 1876 through 2001. Each record is the data for a specific team in a specific year, and the several fields in a record show the number of home runs, the number of strikeouts, etc., that the team accumulated for that season.

It's simple to extract the data for a single year using the sumproduct formula, and if I rewrite the formula, I can get all the data from a certain forward or all data before that year.

=sumproduct((A3:A1000=1995)*(B3:B1000="Team")*(C2:C1000)) gets data from 1995 for the variable "Team"
=sumproduct((A3:A1000>=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1995 through 2001
=sumproduct((A3:A1000<=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1876 through 1995

The problem is that the formulas must be changed, which is tedious, and there is no way that I can think of to handle a range of years from the middle, e.g.. 1945-1958. Is there some way to do this with sumproducts and maybe named ranges (FirstYear, LastYear)?

Thanks,
Cliff

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
On 2002-09-06 08:35, baseball wrote:
I have a table of yearly statistics for baseball teams from 1876 through 2001. Each record is the data for a specific team in a specific year, and the several fields in a record show the number of home runs, the number of strikeouts, etc., that the team accumulated for that season.

It's simple to extract the data for a single year using the sumproduct formula, and if I rewrite the formula, I can get all the data from a certain forward or all data before that year.

=sumproduct((A3:A1000=1995)*(B3:B1000="Team")*(C2:C1000)) gets data from 1995 for the variable "Team"
=sumproduct((A3:A1000>=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1995 through 2001
=sumproduct((A3:A1000<=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1876 through 1995

The problem is that the formulas must be changed, which is tedious, and there is no way that I can think of to handle a range of years from the middle, e.g.. 1945-1958. Is there some way to do this with sumproducts and maybe named ranges (FirstYear, LastYear)?

Thanks,
Cliff

=SUMPRODUCT((A3:A1000>=E1)*(A3:A1000<=E2)*(B3:B1000="Team")*(C2:C1000))

where E1 houses a year of interest and E2 another with E1 < E2.

On 2002-09-06 08:43, Aladin Akyurek wrote:
On 2002-09-06 08:35, baseball wrote:
I have a table of yearly statistics for baseball teams from 1876 through 2001. Each record is the data for a specific team in a specific year, and the several fields in a record show the number of home runs, the number of strikeouts, etc., that the team accumulated for that season.

It's simple to extract the data for a single year using the sumproduct formula, and if I rewrite the formula, I can get all the data from a certain forward or all data before that year.

=sumproduct((A3:A1000=1995)*(B3:B1000="Team")*(C2:C1000)) gets data from 1995 for the variable "Team"
=sumproduct((A3:A1000>=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1995 through 2001
=sumproduct((A3:A1000<=1995)*(B3:B1000="Team")*(C2:C1000)) gets it from 1876 through 1995

The problem is that the formulas must be changed, which is tedious, and there is no way that I can think of to handle a range of years from the middle, e.g.. 1945-1958. Is there some way to do this with sumproducts and maybe named ranges (FirstYear, LastYear)?

Thanks,
Cliff

=SUMPRODUCT((A3:A1000>=E1)*(A3:A1000<=E2)*(B3:B1000="Team")*(C2:C1000))

where E1 houses a year of interest and E2 another with E1 < E2.

Thanks. That was quick...and easy. I was trying to use the AND function in conjunction with sumproduct, but I didn't think of doing it your way.

Thanks again,
Cliff

Replies
5
Views
362
Replies
7
Views
851
Replies
2
Views
449
Replies
6
Views
499
Replies
6
Views
654

1,216,110
Messages
6,128,895
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back