![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 31
|
Hello
I have a sheet for employee ages & salaries , I want for example (count of employees age between 20-25 years old & the sum salaries amount for this range ) |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,805
|
Quote:
One of the formulas you can use is: =SUMIF(A:A,">=20",B:B)-SUMIF(A:A,">25",B:B) Where in column A you have ages and wages in column B. Eli |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 31
|
Thank I got the sum of the range , the missing part is the count of the range (how many employee between 20-25 years?)
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
Try this :
="There are "&SUMPRODUCT((A1:A100<26)*(A1:A100>19))&" employees between 20 & 25 years with a total salary of £"&SUMIF(A:A,">=20",B:B)-SUMIF(A:A,">25",B:B) For the sumproduct to work correctly you must have the size of the two arrays the same. |
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,805
|
Quote:
For count: =COUNTIF(A:A,">=20")-COUNTIF(A:A,">25") Eli |
|
|
|
|
|
|
#6 |
|
New Member
Join Date: Apr 2002
Posts: 31
|
Thank you folks I'm almost there , one small condition , how to get the highest salary amount among that range (20-25)?
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
Here tou go :
=INDIRECT("B"&MAX(ROW(A2:A25)*(A2:A25<=26)*(A2:A25>19))) Again, you will need to ensure the array ranges are the same. |
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
=MAX(IF((A2:A100>=20)*(A2:A100),B2:B100)) In order to array-enter a formula, you need to hit control+shift+enter at the same time, not just enter. Note. You can't use whole columns in array formulas, something that you can do in SUMIF and COUNTIF formulas (see Eli's replies). I'd suggest using in all these formulas definite ranges (or better dynamic name ranges). Aladin |
|
|
|
|
|
|
#9 | |||||||||||||||||||||||||||
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Let's not overlook the use of a PivotTable which is well suited for this type of request. Given the following data...
*
…you’d get… *
* |
|||||||||||||||||||||||||||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|