Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Remove a criteria from countif based on user selection

Hello!

I am trying to design an output for my spreadsheet which shows the
number of items in a list that match user selected criteria. For
example with the following data set:

A B
1 Male? Over 18?
2 TRUE TRUE
3 TRUE FALSE
4 FALSE TRUE
5 FALSE FALSE
6 FALSE TRUE

I would use the following function:

=COUNTIFS($A$2:$A$6,[User input 1],$B$2:$B$6,[User input 2])

Where the user inputs are TRUE or FALSE drop down boxes that allow the
user to select the gender and age categories they wish to count.

I wish to amend this formula so that I can have a "Don't Care" option
in my user inputs. This would allow the user to count the number of
items that match only one of the criteria.

The real life version of this has a large number of columns all
containing booleans.

I do not want to use a pivot table for this.

Does anybody know how I could achieve this?

Thanks

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Remove a criteria from countif based on user selection

On Sep 27, 11:09*am, JT wrote:
Hello!

I am trying to design an output for my spreadsheet which shows the
number of items in a list that match user selected criteria. *For
example with the following data set:

* *A * * * * * * B
1 Male? * * *Over 18?
2 TRUE * * * TRUE
3 TRUE * * * FALSE
4 FALSE * * TRUE
5 FALSE * * FALSE
6 FALSE * * TRUE

I would use the following function:

=COUNTIFS($A$2:$A$6,[User input 1],$B$2:$B$6,[User input 2])

Where the user inputs are TRUE or FALSE drop down boxes that allow the
user to select the gender and age categories they wish to count.

I wish to amend this formula so that I can have a "Don't Care" option
in my user inputs. *This would allow the user to count the number of
items that match only one of the criteria.

The real life version of this has a large number of columns all
containing booleans.

I do not want to use a pivot table for this.

Does anybody know how I could achieve this?

Thanks

John


How about a worksheet_change event in the sheet module tied to the
drop down that amends the formula(s).
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Remove a criteria from countif based on user selection

Thanks Don

I'm trying to do this without the use of VBA and think I'm on the
verge of cracking it. I can use sumproduct to achieve the same result
as countifs as follows:

A B
1 Male? Over 18?
2 TRUE TRUE
3 TRUE FALSE
4 FALSE TRUE
5 FALSE FALSE
6 FALSE TRUE

=SUMPRODUCT(1*($A$2:$A$6=[User input 1]),1*($B$2:$B$6,[User input 2]))

Where the user inputs are TRUE or FALSE drop down boxes that allow the
user to select the gender and age categories they wish to count.

If the user inputs are both true, this is equivalent to the following:
=SUMPRODUCT({1,1,0,0,0},{1,0,1,0,1})

To add a facility to allow the user to state that they don't care
whether a criteria is true or false, all I need to do is find a way of
forcing all values in the relevant array to be 1. I have managed to
force them all to be zero simply by multiplying the array by zero but
this doesn't give me the result I need.

Can anyone help me with this final step?

Thanks

John
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Remove a criteria from countif based on user selection

How about:

=SUMPRODUCT((IF([UserInput 1]="Don'tCare",1;$A$2:$A$6=[UserInput
1]))*($B$2:$B$6=[UserInput 2]))

NB!! this is an arrayEnter formula, i.e., enter it with Ctrl+Shift
+Enter - so that the IF function would return an array.

Does it work?

On Oct 4, 10:35*am, JT wrote:
Thanks Don

I'm trying to do this without the use of VBA and think I'm on the
verge of cracking it. *I can use sumproduct to achieve the same result
as countifs as follows:

* *A * * * * * * B
1 Male? * * *Over 18?
2 TRUE * * * TRUE
3 TRUE * * * FALSE
4 FALSE * * TRUE
5 FALSE * * FALSE
6 FALSE * * TRUE

=SUMPRODUCT(1*($A$2:$A$6=[User input 1]),1*($B$2:$B$6,[User input 2]))

Where the user inputs are TRUE or FALSE drop down boxes that allow the
user to select the gender and age categories they wish to count.

If the user inputs are both true, this is equivalent to the following:
=SUMPRODUCT({1,1,0,0,0},{1,0,1,0,1})

To add a facility to allow the user to state that they don't care
whether a criteria is true or false, all I need to do is find a way of
forcing all values in the relevant array to be 1. *I have managed to
force them all to be zero simply by multiplying the array by zero but
this doesn't give me the result I need.

Can anyone help me with this final step?

Thanks

John


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Remove a criteria from countif based on user selection

On 4 Oct, 10:53, AB wrote:
How about:

=SUMPRODUCT((IF([UserInput 1]="Don'tCare",1;$A$2:$A$6=[UserInput
1]))*($B$2:$B$6=[UserInput 2]))

NB!! this is an arrayEnter formula, i.e., enter it with Ctrl+Shift
+Enter - so that the IF function would return an array.

Does it work?

On Oct 4, 10:35*am, JT wrote:



Thanks Don


I'm trying to do this without the use of VBA and think I'm on the
verge of cracking it. *I can use sumproduct to achieve the same result
ascountifsas follows:


* *A * * * * * * B
1 Male? * * *Over 18?
2 TRUE * * * TRUE
3 TRUE * * * FALSE
4 FALSE * * TRUE
5 FALSE * * FALSE
6 FALSE * * TRUE


=SUMPRODUCT(1*($A$2:$A$6=[User input 1]),1*($B$2:$B$6,[User input 2]))


Where the user inputs are TRUE or FALSE drop down boxes that allow the
user to select the gender and age categories they wish to count.


If the user inputs are both true, this is equivalent to the following:
=SUMPRODUCT({1,1,0,0,0},{1,0,1,0,1})


To add a facility to allow the user to state that they don't care
whether a criteria is true or false, all I need to do is find a way of
forcing all values in the relevant array to be 1. *I have managed to
force them all to be zero simply by multiplying the array by zero but
this doesn't give me the result I need.


Can anyone help me with this final step?


Thanks


John- Hide quoted text -


- Show quoted text -


Is there a way of doing this without an array formula?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Remove a criteria from countif based on user selection

Not that i'm aware of. I'm more like a vba-kinda-guy and hence my
formulas tend to be not as sophisticated.
At the same time i'm thinking that you need an array to be returned
for that sumproduct to calculate correctly and for IF to return an
array it needs to be array-entered...
There is nothing wrong with array formulas it's just that user needs
to know/remember how to enter them...


On Oct 4, 1:54*pm, JT wrote:
On 4 Oct, 10:53, AB wrote:





How about:


=SUMPRODUCT((IF([UserInput 1]="Don'tCare",1;$A$2:$A$6=[UserInput
1]))*($B$2:$B$6=[UserInput 2]))


NB!! this is an arrayEnter formula, i.e., enter it with Ctrl+Shift
+Enter - so that the IF function would return an array.


Does it work?


On Oct 4, 10:35*am, JT wrote:


Thanks Don


I'm trying to do this without the use of VBA and think I'm on the
verge of cracking it. *I can use sumproduct to achieve the same result
ascountifsas follows:


* *A * * * * * * B
1 Male? * * *Over 18?
2 TRUE * * * TRUE
3 TRUE * * * FALSE
4 FALSE * * TRUE
5 FALSE * * FALSE
6 FALSE * * TRUE


=SUMPRODUCT(1*($A$2:$A$6=[User input 1]),1*($B$2:$B$6,[User input 2]))


Where the user inputs are TRUE or FALSE drop down boxes that allow the
user to select the gender and age categories they wish to count.


If the user inputs are both true, this is equivalent to the following:
=SUMPRODUCT({1,1,0,0,0},{1,0,1,0,1})


To add a facility to allow the user to state that they don't care
whether a criteria is true or false, all I need to do is find a way of
forcing all values in the relevant array to be 1. *I have managed to
force them all to be zero simply by multiplying the array by zero but
this doesn't give me the result I need.


Can anyone help me with this final step?


Thanks


John- Hide quoted text -


- Show quoted text -


Is there a way of doing this without an array formula?- Hide quoted text -

- Show quoted text -


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
Countif based on two criteria MJKelly Excel Worksheet Functions 4 October 13th 08 03:39 PM
Need to combine countIF with AND for selection criteria MikeB Excel Discussion (Misc queries) 1 June 18th 08 01:58 AM
Selection of Cells based on a criteria Scott Excel Discussion (Misc queries) 2 July 27th 07 04:47 PM
Countif based on 2 criteria N E Body Excel Worksheet Functions 5 August 22nd 05 02:15 AM
Compiling values based on selection criteria Bartholomew Simpson Excel Programming 2 August 5th 04 08:30 PM


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