Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default formula to find how many cell have a number between 2 numbers.

I have a column that counts the number of days a person in assigned to my
unit. I am trying to make a formula to count how many people have been in my
unit for 1-30 days, 31-60 days and 61-90 days.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default formula to find how many cell have a number between 2 numbers.

Here are a few options

Example:
With this list in A1:B9
Name Days
Alpha 15
Bravo 22
Charlie 29
Delta 36
Echo 43
Foxtrot 50
Golf 57
Hotel 64

and these start/end numbers in D1:E3
1 30
31 60
61 90

Then....for a traditional approach:
OPTION_1
F1: =SUMPRODUCT(($B$2:$B$9=D1)*($B$2:$B$9<=E1))

OR.....Since your ranges are in tidy groups of 30:
OPTION_2
F1: =SUMPRODUCT(--(CEILING($B$2:$B$9,30)=E1))

OR....for a non-traditional approach:
F1: =INDEX(FREQUENCY($B$2:$B$9,D1:E1-{1,0}),2)

Copy whichever formula you choose down, copy it through F3

Using my posted example:
F1 returns 3
F2 returns 4
F3 returns 1

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron (XL2003, Win XP)
Microsoft MVP (Excel)



"SCOTTAFRED" wrote in message
...
I have a column that counts the number of days a person in assigned to my
unit. I am trying to make a formula to count how many people have been in
my
unit for 1-30 days, 31-60 days and 61-90 days.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default formula to find how many cell have a number between 2 numbers.

One more common approach...(still using the example I posted):

F1: =COUNTIF($B$2:$B$9,"<="&E1)-COUNTIF($B$2:$B$9,"<"&D1)

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

Regards,

Ron (XL2003, Win XP)
Microsoft MVP (Excel)


"Ron Coderre" wrote in message
...
Here are a few options

Example:
With this list in A1:B9
Name Days
Alpha 15
Bravo 22
Charlie 29
Delta 36
Echo 43
Foxtrot 50
Golf 57
Hotel 64

and these start/end numbers in D1:E3
1 30
31 60
61 90

Then....for a traditional approach:
OPTION_1
F1: =SUMPRODUCT(($B$2:$B$9=D1)*($B$2:$B$9<=E1))

OR.....Since your ranges are in tidy groups of 30:
OPTION_2
F1: =SUMPRODUCT(--(CEILING($B$2:$B$9,30)=E1))

OR....for a non-traditional approach:
F1: =INDEX(FREQUENCY($B$2:$B$9,D1:E1-{1,0}),2)

Copy whichever formula you choose down, copy it through F3

Using my posted example:
F1 returns 3
F2 returns 4
F3 returns 1

Does that help?
Post back if you have more questions.
--------------------------

Regards,

Ron (XL2003, Win XP)
Microsoft MVP (Excel)



"SCOTTAFRED" wrote in message
...
I have a column that counts the number of days a person in assigned to my
unit. I am trying to make a formula to count how many people have been
in my
unit for 1-30 days, 31-60 days and 61-90 days.





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 783
Default formula to find how many cell have a number between 2 numbers.

SCOTTAFRED wrote:
I have a column that counts the number of days a person in assigned to my
unit. I am trying to make a formula to count how many people have been in my
unit for 1-30 days, 31-60 days and 61-90 days.


Three versions of a function to do this were recently posted in this
forum; watch for wordwrap:

Public Function CountBetw( _
iRange As Range, _
lowNum As Double, _
hiNum As Double, _
Optional inclLow = True, _
Optional inclHi = True) As Variant
With Application
CountBetw = .CountIf(iRange, "" & String(-inclLow, "=") & lowNum) - _
.CountIf(iRange, "" & String(-Not (inclHi), "=") & hiNum)
End With
End Function

Rick Rothstein

Public Function CountBetw( _
iRange As Range, _
lowNum As Double, _
hiNum As Double, _
Optional inclLow = True, _
Optional inclHi = True) As Variant
Dim sOpLow As String
Dim sOpHi As String
sOpLow = IIf(inclLow, "=", "")
sOpHi = IIf(inclHi, "", "=")
With Application
CountBetw = .CountIf(iRange, sOpLow & lowNum) - _
.CountIf(iRange, sOpHi & hiNum)
End With
End Function

JE McGimpsey

Function CountBetw(iRange As range, lowNum, hiNum, Optional inclLow =
True, Optional inclHi = True)
If inclLow = True And inclHi = True Then
CountBetw = Application.CountIf(iRange, "=" & lowNum) -
Application.CountIf(iRange, "" & hiNum)
ElseIf inclLow = False And inclHi = False Then
CountBetw = Application.CountIf(iRange, "" & lowNum) -
Application.CountIf(iRange, "=" & hiNum)
ElseIf inclLow = True And inclHi = False Then
CountBetw = Application.CountIf(iRange, "=" & lowNum) -
Application.CountIf(iRange, "=" & hiNum)
ElseIf inclLow = False And inclHi = True Then
CountBetw = Application.CountIf(iRange, "" & lowNum) -
Application.CountIf(iRange, "" & hiNum)
End If
End Function

Alan Beban
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
Find numbers in an array that sum to a certain number tommydancer Excel Worksheet Functions 3 September 9th 06 03:11 PM
extract number and use in formula from text & numbers in cell ivory_kitten Excel Worksheet Functions 3 July 14th 06 05:38 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 3 January 19th 06 09:52 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 1 January 9th 06 01:23 PM
How do I find the last number in a column of numbers? Shyam Excel Worksheet Functions 2 August 26th 05 03:05 AM


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