PC Review


Reply
Thread Tools Rate Thread

COUNTIF greater than one column and less than another

 
 
Nadine
Guest
Posts: n/a
 
      7th May 2009
I am attempting to write a COUNTIF statement with greater than and less than
functionality. I have 2 worksheets.

Sheet 1 contains the extracted data from a database – this cannot be
changed.
Row A is a sequential number of the items.
Row B contains the status (New, In Progress, Closed).
Row C contains the day and time the item was created.
Row D contains the day and time the item was closed.
Cell F2 contains: =MONTH(C2)&"-"&YEAR(C2)
Cell G2 contains: =IF(B2="Closed", MONTH(C2)&"-"&YEAR(C2),"")

Sheet 2 has the 6 month reporting period as shown below:
Cell B1 is for the user to enter the MM-YYYY of the first reporting month
Cell B2 contains the following formula: =DATE(YEAR(B1),MONTH(B1)+C2,DAY(B1))
to return the MM-YYYY 1 greater than the month in cell B1. This continues
through B6 so I have 6 months in a row.
Cell A16 says: =B1 to return the MM-YYYY of the first month for reporting.
Cell B16 says: =B2 and so on through cell F16
Row 17 is where I want the results of the COUNTIF formula to begin.
Cell A17 says: =COUNTIF(Sheet1!$F:$F,Sheet2!A16) to tell me how many were
opened in the month displayed in cell A16.
Cell A18 says: =COUNTIF(Sheet1!$G:$G,Sheet2!A16) to tell me how many were
closed during the month displayed in cell A16.
Now I have the number of items opened and the number of items closed in each
month.

What I need to know is how many OPEN items I had at the beginning of the
current month. Remember that the months in row 16 will changed based on what
the user enters in cell B2. (This workbook is to be used as a template so it
will constantly be changing.)

I've tried using the formula for COUNTIF in the help section:
=COUNTIF(Sheet1!$F:$F,"<Sheet2!A16")-COUNTIF(Sheet1!$G:$G,">Sheet2!B16") to
tell me how many were open at the beginning (12:01am) of the second month.
The result was 11 which is incorrect as only 1 item was created in the first
month and it is still open. So the result should have been 1.

Thanks for any help.

 
Reply With Quote
 
 
 
 
JBeaucaire
Guest
Posts: n/a
 
      7th May 2009
I use SUMPRODUCT() to accomplish counting like you're describing. This
function is WAY more flexible than people realize at first. This link has a
wonderful tutorial and the really good stuff is down the sheet a ways past
the "Advantages of Sumproduct"

http://www.xldynamic.com/source/xld....T.html#classic

Read up on that. Then I imagine a formula for count of open items spanning
many months to be something like this:

=SUMPRODUCT(--(RangeOfOpeningDates>=OpeningDate),
--(RangeOfOpeningDates<CutoffOpenDate),
--(RangeOfClosingDates>CutoffOpenDate))

Now, just insert the correct ranges and cell references for those values.
With Sumproduct, you can't refer to whole columns like you can with COUNTIF
unless you're using Excel 2007
--
"Actually, I *am* a rocket scientist." -- JB

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


"Nadine" wrote:

> I am attempting to write a COUNTIF statement with greater than and less than
> functionality. I have 2 worksheets.
>
> Sheet 1 contains the extracted data from a database – this cannot be
> changed.
> Row A is a sequential number of the items.
> Row B contains the status (New, In Progress, Closed).
> Row C contains the day and time the item was created.
> Row D contains the day and time the item was closed.
> Cell F2 contains: =MONTH(C2)&"-"&YEAR(C2)
> Cell G2 contains: =IF(B2="Closed", MONTH(C2)&"-"&YEAR(C2),"")
>
> Sheet 2 has the 6 month reporting period as shown below:
> Cell B1 is for the user to enter the MM-YYYY of the first reporting month
> Cell B2 contains the following formula: =DATE(YEAR(B1),MONTH(B1)+C2,DAY(B1))
> to return the MM-YYYY 1 greater than the month in cell B1. This continues
> through B6 so I have 6 months in a row.
> Cell A16 says: =B1 to return the MM-YYYY of the first month for reporting.
> Cell B16 says: =B2 and so on through cell F16
> Row 17 is where I want the results of the COUNTIF formula to begin.
> Cell A17 says: =COUNTIF(Sheet1!$F:$F,Sheet2!A16) to tell me how many were
> opened in the month displayed in cell A16.
> Cell A18 says: =COUNTIF(Sheet1!$G:$G,Sheet2!A16) to tell me how many were
> closed during the month displayed in cell A16.
> Now I have the number of items opened and the number of items closed in each
> month.
>
> What I need to know is how many OPEN items I had at the beginning of the
> current month. Remember that the months in row 16 will changed based on what
> the user enters in cell B2. (This workbook is to be used as a template so it
> will constantly be changing.)
>
> I've tried using the formula for COUNTIF in the help section:
> =COUNTIF(Sheet1!$F:$F,"<Sheet2!A16")-COUNTIF(Sheet1!$G:$G,">Sheet2!B16") to
> tell me how many were open at the beginning (12:01am) of the second month.
> The result was 11 which is incorrect as only 1 item was created in the first
> month and it is still open. So the result should have been 1.
>
> Thanks for any help.
>

 
Reply With Quote
 
 
 
 
Nadine
Guest
Posts: n/a
 
      8th May 2009
I entered the formula
=SUMPRODUCT((Sheet1!F:F<Sheet2!C16)*(Sheet1!G:G>Sheet2!C16)) and received
#NUM! as the result. Thanks for the link, though. I will keep it and
continue reading up on SUMPRODUCT to see if there's another way to write it
that will give me the result I need.
Nadine

"JBeaucaire" wrote:

> I use SUMPRODUCT() to accomplish counting like you're describing. This
> function is WAY more flexible than people realize at first. This link has a
> wonderful tutorial and the really good stuff is down the sheet a ways past
> the "Advantages of Sumproduct"
>
> http://www.xldynamic.com/source/xld....T.html#classic
>
> Read up on that. Then I imagine a formula for count of open items spanning
> many months to be something like this:
>
> =SUMPRODUCT(--(RangeOfOpeningDates>=OpeningDate),
> --(RangeOfOpeningDates<CutoffOpenDate),
> --(RangeOfClosingDates>CutoffOpenDate))
>
> Now, just insert the correct ranges and cell references for those values.
> With Sumproduct, you can't refer to whole columns like you can with COUNTIF
> unless you're using Excel 2007
> --
> "Actually, I *am* a rocket scientist." -- JB
>
> Your feedback is appreciated, click YES if this post helped you.
>
>
> "Nadine" wrote:
>
> > I am attempting to write a COUNTIF statement with greater than and less than
> > functionality. I have 2 worksheets.
> >
> > Sheet 1 contains the extracted data from a database – this cannot be
> > changed.
> > Row A is a sequential number of the items.
> > Row B contains the status (New, In Progress, Closed).
> > Row C contains the day and time the item was created.
> > Row D contains the day and time the item was closed.
> > Cell F2 contains: =MONTH(C2)&"-"&YEAR(C2)
> > Cell G2 contains: =IF(B2="Closed", MONTH(C2)&"-"&YEAR(C2),"")
> >
> > Sheet 2 has the 6 month reporting period as shown below:
> > Cell B1 is for the user to enter the MM-YYYY of the first reporting month
> > Cell B2 contains the following formula: =DATE(YEAR(B1),MONTH(B1)+C2,DAY(B1))
> > to return the MM-YYYY 1 greater than the month in cell B1. This continues
> > through B6 so I have 6 months in a row.
> > Cell A16 says: =B1 to return the MM-YYYY of the first month for reporting.
> > Cell B16 says: =B2 and so on through cell F16
> > Row 17 is where I want the results of the COUNTIF formula to begin.
> > Cell A17 says: =COUNTIF(Sheet1!$F:$F,Sheet2!A16) to tell me how many were
> > opened in the month displayed in cell A16.
> > Cell A18 says: =COUNTIF(Sheet1!$G:$G,Sheet2!A16) to tell me how many were
> > closed during the month displayed in cell A16.
> > Now I have the number of items opened and the number of items closed in each
> > month.
> >
> > What I need to know is how many OPEN items I had at the beginning of the
> > current month. Remember that the months in row 16 will changed based on what
> > the user enters in cell B2. (This workbook is to be used as a template so it
> > will constantly be changing.)
> >
> > I've tried using the formula for COUNTIF in the help section:
> > =COUNTIF(Sheet1!$F:$F,"<Sheet2!A16")-COUNTIF(Sheet1!$G:$G,">Sheet2!B16") to
> > tell me how many were open at the beginning (12:01am) of the second month.
> > The result was 11 which is incorrect as only 1 item was created in the first
> > month and it is still open. So the result should have been 1.
> >
> > Thanks for any help.
> >

 
Reply With Quote
 
JBeaucaire
Guest
Posts: n/a
 
      8th May 2009
You need to read my original suggestion again. I mentioned that sumproduct
can't refer to an entire column. Simply use an actual range, sufficiently
large to cover your needs. Sumproduct is the function for this.

--
"Actually, I *am* a rocket scientist." -- JB

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


"Nadine" wrote:

> I entered the formula
> =SUMPRODUCT((Sheet1!F:F<Sheet2!C16)*(Sheet1!G:G>Sheet2!C16)) and received
> #NUM! as the result. Thanks for the link, though. I will keep it and
> continue reading up on SUMPRODUCT to see if there's another way to write it
> that will give me the result I need.
> Nadine
>
> "JBeaucaire" wrote:
>
> > I use SUMPRODUCT() to accomplish counting like you're describing. This
> > function is WAY more flexible than people realize at first. This link has a
> > wonderful tutorial and the really good stuff is down the sheet a ways past
> > the "Advantages of Sumproduct"
> >
> > http://www.xldynamic.com/source/xld....T.html#classic
> >
> > Read up on that. Then I imagine a formula for count of open items spanning
> > many months to be something like this:
> >
> > =SUMPRODUCT(--(RangeOfOpeningDates>=OpeningDate),
> > --(RangeOfOpeningDates<CutoffOpenDate),
> > --(RangeOfClosingDates>CutoffOpenDate))
> >
> > Now, just insert the correct ranges and cell references for those values.
> > With Sumproduct, you can't refer to whole columns like you can with COUNTIF
> > unless you're using Excel 2007
> > --
> > "Actually, I *am* a rocket scientist." -- JB
> >
> > Your feedback is appreciated, click YES if this post helped you.
> >
> >
> > "Nadine" wrote:
> >
> > > I am attempting to write a COUNTIF statement with greater than and less than
> > > functionality. I have 2 worksheets.
> > >
> > > Sheet 1 contains the extracted data from a database – this cannot be
> > > changed.
> > > Row A is a sequential number of the items.
> > > Row B contains the status (New, In Progress, Closed).
> > > Row C contains the day and time the item was created.
> > > Row D contains the day and time the item was closed.
> > > Cell F2 contains: =MONTH(C2)&"-"&YEAR(C2)
> > > Cell G2 contains: =IF(B2="Closed", MONTH(C2)&"-"&YEAR(C2),"")
> > >
> > > Sheet 2 has the 6 month reporting period as shown below:
> > > Cell B1 is for the user to enter the MM-YYYY of the first reporting month
> > > Cell B2 contains the following formula: =DATE(YEAR(B1),MONTH(B1)+C2,DAY(B1))
> > > to return the MM-YYYY 1 greater than the month in cell B1. This continues
> > > through B6 so I have 6 months in a row.
> > > Cell A16 says: =B1 to return the MM-YYYY of the first month for reporting.
> > > Cell B16 says: =B2 and so on through cell F16
> > > Row 17 is where I want the results of the COUNTIF formula to begin.
> > > Cell A17 says: =COUNTIF(Sheet1!$F:$F,Sheet2!A16) to tell me how many were
> > > opened in the month displayed in cell A16.
> > > Cell A18 says: =COUNTIF(Sheet1!$G:$G,Sheet2!A16) to tell me how many were
> > > closed during the month displayed in cell A16.
> > > Now I have the number of items opened and the number of items closed in each
> > > month.
> > >
> > > What I need to know is how many OPEN items I had at the beginning of the
> > > current month. Remember that the months in row 16 will changed based on what
> > > the user enters in cell B2. (This workbook is to be used as a template so it
> > > will constantly be changing.)
> > >
> > > I've tried using the formula for COUNTIF in the help section:
> > > =COUNTIF(Sheet1!$F:$F,"<Sheet2!A16")-COUNTIF(Sheet1!$G:$G,">Sheet2!B16") to
> > > tell me how many were open at the beginning (12:01am) of the second month.
> > > The result was 11 which is incorrect as only 1 item was created in the first
> > > month and it is still open. So the result should have been 1.
> > >
> > > Thanks for any help.
> > >

 
Reply With Quote
 
Nadine
Guest
Posts: n/a
 
      8th May 2009
Sorry. I missed that in your original response. Unfortunately I need the
whole column as it they data in the column will continually grow. With
limiting the end it will, at some point, no longer see all the data. I think
I've found a way around my problem with making a few changes in other cells
and formulas.

"JBeaucaire" wrote:

> You need to read my original suggestion again. I mentioned that sumproduct
> can't refer to an entire column. Simply use an actual range, sufficiently
> large to cover your needs. Sumproduct is the function for this.
>
> --
> "Actually, I *am* a rocket scientist." -- JB
>
> Your feedback is appreciated, click YES if this post helped you.
>
>
> "Nadine" wrote:
>
> > I entered the formula
> > =SUMPRODUCT((Sheet1!F:F<Sheet2!C16)*(Sheet1!G:G>Sheet2!C16)) and received
> > #NUM! as the result. Thanks for the link, though. I will keep it and
> > continue reading up on SUMPRODUCT to see if there's another way to write it
> > that will give me the result I need.
> > Nadine
> >
> > "JBeaucaire" wrote:
> >
> > > I use SUMPRODUCT() to accomplish counting like you're describing. This
> > > function is WAY more flexible than people realize at first. This link has a
> > > wonderful tutorial and the really good stuff is down the sheet a ways past
> > > the "Advantages of Sumproduct"
> > >
> > > http://www.xldynamic.com/source/xld....T.html#classic
> > >
> > > Read up on that. Then I imagine a formula for count of open items spanning
> > > many months to be something like this:
> > >
> > > =SUMPRODUCT(--(RangeOfOpeningDates>=OpeningDate),
> > > --(RangeOfOpeningDates<CutoffOpenDate),
> > > --(RangeOfClosingDates>CutoffOpenDate))
> > >
> > > Now, just insert the correct ranges and cell references for those values.
> > > With Sumproduct, you can't refer to whole columns like you can with COUNTIF
> > > unless you're using Excel 2007
> > > --
> > > "Actually, I *am* a rocket scientist." -- JB
> > >
> > > Your feedback is appreciated, click YES if this post helped you.
> > >
> > >
> > > "Nadine" wrote:
> > >
> > > > I am attempting to write a COUNTIF statement with greater than and less than
> > > > functionality. I have 2 worksheets.
> > > >
> > > > Sheet 1 contains the extracted data from a database – this cannot be
> > > > changed.
> > > > Row A is a sequential number of the items.
> > > > Row B contains the status (New, In Progress, Closed).
> > > > Row C contains the day and time the item was created.
> > > > Row D contains the day and time the item was closed.
> > > > Cell F2 contains: =MONTH(C2)&"-"&YEAR(C2)
> > > > Cell G2 contains: =IF(B2="Closed", MONTH(C2)&"-"&YEAR(C2),"")
> > > >
> > > > Sheet 2 has the 6 month reporting period as shown below:
> > > > Cell B1 is for the user to enter the MM-YYYY of the first reporting month
> > > > Cell B2 contains the following formula: =DATE(YEAR(B1),MONTH(B1)+C2,DAY(B1))
> > > > to return the MM-YYYY 1 greater than the month in cell B1. This continues
> > > > through B6 so I have 6 months in a row.
> > > > Cell A16 says: =B1 to return the MM-YYYY of the first month for reporting.
> > > > Cell B16 says: =B2 and so on through cell F16
> > > > Row 17 is where I want the results of the COUNTIF formula to begin.
> > > > Cell A17 says: =COUNTIF(Sheet1!$F:$F,Sheet2!A16) to tell me how many were
> > > > opened in the month displayed in cell A16.
> > > > Cell A18 says: =COUNTIF(Sheet1!$G:$G,Sheet2!A16) to tell me how many were
> > > > closed during the month displayed in cell A16.
> > > > Now I have the number of items opened and the number of items closed in each
> > > > month.
> > > >
> > > > What I need to know is how many OPEN items I had at the beginning of the
> > > > current month. Remember that the months in row 16 will changed based on what
> > > > the user enters in cell B2. (This workbook is to be used as a template so it
> > > > will constantly be changing.)
> > > >
> > > > I've tried using the formula for COUNTIF in the help section:
> > > > =COUNTIF(Sheet1!$F:$F,"<Sheet2!A16")-COUNTIF(Sheet1!$G:$G,">Sheet2!B16") to
> > > > tell me how many were open at the beginning (12:01am) of the second month.
> > > > The result was 11 which is incorrect as only 1 item was created in the first
> > > > month and it is still open. So the result should have been 1.
> > > >
> > > > Thanks for any help.
> > > >

 
Reply With Quote
 
Justin Case
Guest
Posts: n/a
 
      8th May 2009
On May 7, 8:05*pm, Nadine <(E-Mail Removed)> wrote:
> Sorry. *I missed that in your original response. *Unfortunately I need the
> whole column as it they data in the column will continually grow. *With
> limiting the end it will, at some point, no longer see all the data. *Ithink
> I've found a way around my problem with making a few changes in other cells
> and formulas.
>
>
>
> "JBeaucaire" wrote:
> > You need to read my original suggestion again. I mentioned that sumproduct
> > can't refer to an entire column. Simply use an actual range, sufficiently
> > large to cover your needs. *Sumproduct is the function for this.

>
> > --
> > "Actually, I *am* a rocket scientist." -- JB

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

>
> > "Nadine" wrote:

>
> > > I entered the formula
> > > =SUMPRODUCT((Sheet1!F:F<Sheet2!C16)*(Sheet1!G:G>Sheet2!C16)) and received
> > > #NUM! as the result. *Thanks for the link, though. *I will keep it and
> > > continue reading up on SUMPRODUCT to see if there's another way to write it
> > > that will give me the result I need.
> > > Nadine

>
> > > "JBeaucaire" wrote:

>
> > > > I use SUMPRODUCT() to accomplish counting like you're describing. This
> > > > function is WAY more flexible than people realize at first. This link has a
> > > > wonderful tutorial and the really good stuff is down the sheet a ways past
> > > > the "Advantages of Sumproduct"

>
> > > >http://www.xldynamic.com/source/xld....T.html#classic

>
> > > > Read up on that. *Then I imagine a formula for count of open items spanning
> > > > many months to be something like this:

>
> > > > =SUMPRODUCT(--(RangeOfOpeningDates>=OpeningDate),
> > > > --(RangeOfOpeningDates<CutoffOpenDate),
> > > > --(RangeOfClosingDates>CutoffOpenDate))

>
> > > > Now, just insert the correct ranges and cell references for those values.
> > > > With Sumproduct, you can't refer to whole columns like you can withCOUNTIF
> > > > unless you're using Excel 2007
> > > > --
> > > > "Actually, I *am* a rocket scientist." -- JB

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

>
> > > > "Nadine" wrote:

>
> > > > > I am attempting to write a COUNTIF statement with greater than and less than
> > > > > functionality. *I have 2 worksheets. *

>
> > > > > Sheet 1 contains the extracted data from a database this cannot be
> > > > > changed. *
> > > > > Row A is a sequential number of the items.
> > > > > Row B contains the status (New, In Progress, Closed).
> > > > > Row C contains the day and time the item was created.
> > > > > Row D contains the day and time the item was closed.
> > > > > Cell F2 contains: =MONTH(C2)&"-"&YEAR(C2)
> > > > > Cell G2 contains: =IF(B2="Closed", MONTH(C2)&"-"&YEAR(C2),"")

>
> > > > > Sheet 2 has the 6 month reporting period as shown below:
> > > > > Cell B1 is for the user to enter the MM-YYYY of the first reporting month
> > > > > Cell B2 contains the following formula: =DATE(YEAR(B1),MONTH(B1)+C2,DAY(B1))
> > > > > to return the MM-YYYY 1 greater than the month in cell B1. *This continues
> > > > > through B6 so I have 6 months in a row.
> > > > > Cell A16 says: =B1 to return the MM-YYYY of the first month forreporting.
> > > > > Cell B16 says: =B2 and so on through cell F16
> > > > > Row 17 is where I want the results of the COUNTIF formula to begin.
> > > > > Cell A17 says: =COUNTIF(Sheet1!$F:$F,Sheet2!A16) to tell me howmany were
> > > > > opened in the month displayed in cell A16.
> > > > > Cell A18 says: =COUNTIF(Sheet1!$G:$G,Sheet2!A16) to tell me howmany were
> > > > > closed during the month displayed in cell A16.
> > > > > Now I have the number of items opened and the number of items closed in each
> > > > > month. *

>
> > > > > What I need to know is how many OPEN items I had at the beginningof the
> > > > > current month. *Remember that the months in row 16 will changedbased on what
> > > > > the user enters in cell B2. *(This workbook is to be used as a template so it
> > > > > will constantly be changing.) *

>
> > > > > I've tried using the formula for COUNTIF in the help section:
> > > > > =COUNTIF(Sheet1!$F:$F,"<Sheet2!A16")-COUNTIF(Sheet1!$G:$G,">Sheet2!B16") to
> > > > > tell me how many were open at the beginning (12:01am) of the second month. *
> > > > > The result was 11 which is incorrect as only 1 item was created in the first
> > > > > month and it is still open. *So the result should have been 1.

>
> > > > > Thanks for any help.- Hide quoted text -

>
> - Show quoted text -


Just a thought, but you can use JB's suggestion simply by including
the entire column range reference i.e.

=SUMPRODUCT((Sheet1!F1:F65536<Sheet2!C16)*(Sheet1!G1:G65536>Sheet2!
C16))

I used the formula you posted, so I didn't actually test on data.

Regards,
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Countif using less than or greater than criteria Kim B. Microsoft Excel Discussion 3 12th Mar 2008 06:30 PM
Sum values greater than x and less than y in a column =?Utf-8?B?Um9va2llX1VzZXI=?= Microsoft Excel Misc 1 20th Jul 2007 05:19 PM
CountIf Greater Than/Find Greater Than Sisilla Microsoft Excel Programming 12 6th Oct 2006 08:04 PM
countif formula to find the occurances of a number that is greater than one number but less than another steveo Microsoft Excel Misc 3 8th Jul 2006 02:04 AM
Excel to COUNTIF if number greater than one but less than another =?Utf-8?B?Um9vc3Rlcjg=?= Microsoft Excel Worksheet Functions 2 24th Oct 2005 10:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:15 PM.